sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
277 stars 30 forks source link

feat: add support for flat config #708

Closed ota-meshi closed 3 months ago

ota-meshi commented 3 months ago

https://eslint.org/blog/2022/08/new-config-system-part-2/ https://eslint.org/docs/latest/use/configure/configuration-files-new

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: e3c0beb84d63dbc79691e6e46d1a21f7547a8dde

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------- | ----- | | eslint-plugin-svelte | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

pxeger commented 3 months ago

This is awesome, thanks! I couldn't get it to work with TypeScript and typed linting though. I guess this is because the svelte parser is overriding languageOptions so parserOptions.project doesn't get forwarded? Or maybe I've just not configured it properly, because Parser surely shouldn't be undefined? (Tested with a new svelte-kit project, with this eslint.config.js)

$ eslint . --max-warnings 0

Oops! Something went wrong! :(

ESLint: 8.57.0

Error: Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Parser: undefined
Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.
Occurred while linting src/routes/+layout.svelte
    at throwError (node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:40:11)
    at getParserServices (node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:20:9)
    at create (node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js:46:55)
    at Object.create (node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:38:20)
    at createRuleListeners (node_modules/eslint/lib/linter/linter.js:895:21)
    at node_modules/eslint/lib/linter/linter.js:1066:110
    at Array.forEach (<anonymous>)
    at runRules (node_modules/eslint/lib/linter/linter.js:1003:34)
    at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (node_modules/eslint/lib/linter/linter.js:1730:31)
    at Linter._verifyWithFlatConfigArray (node_modules/eslint/lib/linter/linter.js:1861:21)
polyzen commented 3 months ago

IMO tseslint shouldn't be pushing everyone to use their ts.config helper. Here's what I managed to come up with: https://gitlab.archlinux.org/archlinux/neoasknot/-/blob/5a71f8b3a402dfc6944fb5da6c44e03180afb8b6/eslint.config.js

Not yet using eslint-plugin-svelte's new flat config stuff as it's still only in next releases.

oosawy commented 3 months ago

I had trouble figuring out why the flat config at the top of README wasn't working and finally got to the fact that it was behind the next tag. that would be better remove the description once