-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update deps; New eslint config; Fix budgeted fs wrapper bug #1185
Conversation
eslint.config.js
Outdated
export default tseslint.config( | ||
{ | ||
ignores: [ | ||
'**/*.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that tseslint isn't already ignoring files not in the tsconfig. Is there a way to do that?
Otherwise, might this help? https://github.com/antfu/eslint-config-flat-gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use a path argument when you run eslint in your npm script, like eslint src/**/*.ts
or whatever?
I like to set eslint up so that you can run it with no path argument. My experience is that when you run eslint with no path argument, it will try and lint all supported files. The tseslint config may only apply to typescript project files, but eslint is still going to try and lint everything else with the non-tseslint rules.
So I think it's still good to have all your non-lintable files listed here.
Syncing with .gitignore makes sense, but I think I'm going skip that plugin since the structure changes so rarely and I don't want to add a dep. I did clean up the list, though.
eslint.config.js
Outdated
], | ||
}, | ||
{ | ||
files: ['**/*.ts'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be src/**/*.ts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think **/*.ts
is actually fine, because if we're globally ignoring all non-source files, then a general ".ts extension" filter seems ok.
This way we don't have to know anything about the project layout, which in this case would also require that we add vscode-extension/src
.
eslint.config.js
Outdated
{ | ||
files: ['**/*.ts'], | ||
languageOptions: { | ||
parser: tseslint.parser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think you had to set the parser manually anymore.
Here's a recent config I made when upgrading to ESLint v9:
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
export default [
eslint.configs.recommended,
eslintPluginPrettierRecommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"@typescript-eslint/no-non-null-assertion": "error"
},
},
];
It doesn't use tseslint.config()
because the config is in .js and doesn't need a type-safe config merger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think you had to set the parser manually anymore.
Huh, you're right! I think I was getting mislead by a combination of things:
-
My config was initially matching .js files not covered by a TypeScript config because I didn't have the right
files
filter. -
eslint then tried to run a TypeScript-parser-depending rule on that js file, but that rule has an outdated error message saying that you need to set a parser. But the real problem was just that it shouldn't have been covered by the TypeScript rule at all.
It doesn't use tseslint.config() because the config is in .js and doesn't need a type-safe config merger.
Ah nice. Didn't realize this was just a typings thing.
Here's a recent config I made when upgrading to ESLint v9:
Cool! I adopted some of this.
The main difference now is that I have this {files: ["**/*.ts"]}
constraint on all the TypeScript setting objects (including the tseslint ones). What I found is that I otherwise get errors with projectService: true
where tseslint is not able to find a tsconfig.json
for the one or two .js
files we have here. A little odd, but I can't find a simpler arrangement after fiddling for a while -- I always end up with some kind of error relating to non-ts files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslintPluginPrettierRecommended,
Oh also, curious why you like using this prettier eslint plugin? (instead of just using the prettier binary).
Update all the dependencies to latest major versions. Only eslint required any changes.
Eslint 9 has a new config file format, so I switched to that. I also adopted the new recommended style for typescript-eslint which has some new rules. The new rules found a few style issues, but also a real issue.
The real issue was that an
await
was being omitted in the budgeted fs module. We could also update tousing
, but let's do that in another PR for the whole project.