Skip to content

Commit

Permalink
fix peerdependency
Browse files Browse the repository at this point in the history
  • Loading branch information
MP281X committed Jun 20, 2024
1 parent c4441b7 commit 3460ce9
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 217 deletions.
75 changes: 22 additions & 53 deletions configs/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ import unicorn from 'eslint-plugin-unicorn'
// @ts-expect-error: no type definitions
import perfectionist from 'eslint-plugin-perfectionist'

// import svelte from 'eslint-plugin-svelte'
// import svelteParser from 'svelte-eslint-parser'
import svelte from 'eslint-plugin-svelte'
import svelteParser from 'svelte-eslint-parser'

import astro from 'eslint-plugin-astro'

// @ts-expect-error: no type definitions
import tailwindcss from 'eslint-plugin-tailwindcss'

import solid from 'eslint-plugin-solid/dist/plugin.js'

// @ts-expect-error: no type definitions
import nextjs from '@next/eslint-plugin-next'
// @ts-expect-error: no type definitions
import react from 'eslint-plugin-react'
import reactFC from 'eslint-plugin-react-prefer-function-component/config'
Expand Down Expand Up @@ -273,57 +269,30 @@ export default ts.config(
settings: { react: { version: 'detect' } }
}),

// nextjs
conditionalConfig('next', {
files: ['**/*.tsx'],
plugins: { '@next/next': nextjs },
rules: {
...nextjs.configs.recommended.rules,
...nextjs.configs['core-web-vitals'].rules
}
}),

// solid
conditionalConfig('solid-js', {
files: ['**/*.tsx'],
plugins: { solid: solid.plugin },
// svelte
conditionalConfig('svelte', {
extends: svelte.configs['flat/recommended'] as any,
files: ['**/*.svelte'],
languageOptions: { parser: svelteParser, parserOptions: { extraFileExtensions: ['.svelte'], parser: ts.parser } },
rules: {
'solid/components-return-once': 'error', // disallow early returns in jsx components
'solid/event-handlers': 'error', // make event handlers names consistent "onclick" -> "onClick"
'solid/jsx-no-script-url': 'error', // allow only valid urls in the href prop
'solid/no-destructure': 'error', // don't deconstruct jsx props
'solid/no-innerhtml': 'error', // don't allow the innerHtml prop
'solid/prefer-for': 'error', // use the <For> components instead of the jsx map
'solid/prefer-show': 'error', // use the <Show> component instead of the jsx ternary
'solid/reactivity': 'error', // prevent reactivity error
'solid/self-closing-comp': ['error', { component: 'all', html: 'all' }] // force self closing tags if there are no chidlren
// eslint-disable-next-line unicorn/no-null
'svelte/block-lang': ['error', { enforceScriptPresent: true, script: ['ts'], style: ['postcss', null] }], // require lang="ts" in the script tag
'svelte/infinite-reactive-loop': 'error', // prevent reactivity bug
'svelte/no-export-load-in-svelte-module-in-kit-pages': 'error', // no function called load in script
'svelte/no-immutable-reactive-statements': 'error', // disable reactive statement for const values
'svelte/no-reactive-reassign': 'error', // don't readding derived reactive values
'svelte/no-store-async': 'error', // disable async await in stores
'svelte/no-useless-mustaches': 'error', // don't allow useless {}
'svelte/sort-attributes': 'off', // already checked by the "perfectionist" plugin
'svelte/valid-prop-names-in-kit-pages': 'error', // disable invalid exports in +page.svelte file

// rules that doesn't work in svelte 5
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off'
}
}),

// svelte
// conditionalConfig('svelte', {
// extends: svelte.configs['flat/recommended'] as any,
// files: ['**/*.svelte'],
// languageOptions: { parser: svelteParser, parserOptions: { extraFileExtensions: ['.svelte'], parser: ts.parser } },
// rules: {
// // eslint-disable-next-line unicorn/no-null
// 'svelte/block-lang': ['error', { enforceScriptPresent: true, script: ['ts'], style: ['postcss', null] }], // require lang="ts" in the script tag
// 'svelte/infinite-reactive-loop': 'error', // prevent reactivity bug
// 'svelte/no-export-load-in-svelte-module-in-kit-pages': 'error', // no function called load in script
// 'svelte/no-immutable-reactive-statements': 'error', // disable reactive statement for const values
// 'svelte/no-reactive-reassign': 'error', // don't readding derived reactive values
// 'svelte/no-store-async': 'error', // disable async await in stores
// 'svelte/no-useless-mustaches': 'error', // don't allow useless {}
// 'svelte/sort-attributes': 'off', // already checked by the "perfectionist" plugin
// 'svelte/valid-prop-names-in-kit-pages': 'error', // disable invalid exports in +page.svelte file
//
// // rules that doesn't work in svelte 5
// '@typescript-eslint/no-unsafe-assignment': 'off',
// '@typescript-eslint/no-unsafe-call': 'off',
// '@typescript-eslint/no-unsafe-member-access': 'off'
// }
// }),

// astro
conditionalConfig('astro', {
extends: astro.configs.recommended,
Expand Down
2 changes: 1 addition & 1 deletion configs/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
arrowParens: 'avoid',
experimentalTernaries: true,
overrides: [{ files: '*.json', options: { parser: 'jsonc' } }],
plugins: ['prettier-plugin-tailwindcss', 'prettier-plugin-astro'],
plugins: ['prettier-plugin-svelte', 'prettier-plugin-tailwindcss', 'prettier-plugin-astro'],
printWidth: 150,
quoteProps: 'consistent',
semi: false,
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@
"./tsconfig": "./configs/tsconfig.json"
},

"peerDependencies": { "svelte": "*" },

"dependencies": {
"@fsouza/prettierd": "latest",
"prettier-plugin-astro": "^0",
"prettier-plugin-svelte": "^3",
"prettier-plugin-tailwindcss": "^0",

"eslint": "^9",
"@eslint/js": "^9",
"typescript-eslint": "^7",
"typescript-eslint": "rc-v8",
"eslint-plugin-astro": "^1",
"eslint-plugin-react": "^7",
"eslint-plugin-solid": "^0",
"eslint-plugin-svelte": "^2",
"eslint-plugin-unicorn": "^53",
"eslint-config-prettier": "^9",
"@next/eslint-plugin-next": "rc",
"eslint-plugin-tailwindcss": "^3",
"eslint-plugin-react-hooks": "beta",
"eslint-plugin-perfectionist": "^2",
Expand All @@ -57,7 +59,5 @@
"tsup": "^8",
"prettier": "^3",
"@types/node": "^20"
},

"pnpm": { "peerDependencyRules": { "allowedVersions": { "eslint": "*" } } }
}
}
Loading

0 comments on commit 3460ce9

Please sign in to comment.