-
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
Changes from 4 commits
ef2b05e
9ad8990
66425d8
7369c40
d356d98
ecfb2a1
4d78d94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import pluginJs from '@eslint/js'; | ||
import noOnlyTests from 'eslint-plugin-no-only-tests'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default tseslint.config( | ||
{ | ||
ignores: [ | ||
'**/*.js', | ||
'**/*.cjs', | ||
'**/*.mjs', | ||
'**/*.d.ts', | ||
'**/.wireit/', | ||
'**/node_modules/', | ||
'lib/', | ||
'vscode-extension/.vscode-test/', | ||
'vscode-extension/lib/', | ||
'vscode-extension/built/', | ||
], | ||
}, | ||
{ | ||
files: ['**/*.ts'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think This way we don't have to know anything about the project layout, which in this case would also require that we add |
||
languageOptions: { | ||
parser: tseslint.parser, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Huh, you're right! I think I was getting mislead by a combination of things:
Ah nice. Didn't realize this was just a typings thing.
Cool! I adopted some of this. The main difference now is that I have this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh also, curious why you like using this prettier eslint plugin? (instead of just using the prettier binary). |
||
parserOptions: { | ||
project: ['./tsconfig.json', './vscode-extension/tsconfig.json'], | ||
}, | ||
}, | ||
plugins: { | ||
'@typescript-eslint': tseslint.plugin, | ||
'no-only-tests': noOnlyTests, | ||
}, | ||
}, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.strictTypeChecked, | ||
{ | ||
rules: { | ||
'no-only-tests/no-only-tests': 'error', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{argsIgnorePattern: '^_', varsIgnorePattern: '^_'}, | ||
], | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-useless-constructor': 'off', | ||
'@typescript-eslint/only-throw-error': 'off', | ||
'@typescript-eslint/no-confusing-void-expression': 'off', | ||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'@typescript-eslint/no-unnecessary-condition': 'off', | ||
'@typescript-eslint/no-unnecessary-type-arguments': 'off', | ||
'@typescript-eslint/no-unnecessary-template-expression': 'off', | ||
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off', | ||
}, | ||
}, | ||
); |
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.