-
Notifications
You must be signed in to change notification settings - Fork 336
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
Add Experimental support of Flat Config #1522
Changes from 7 commits
5a2703f
cba18ee
1b4f277
1efd8fd
87b97de
d5964ab
ef614e2
f9d0478
18f706a
a756c4d
d2ab5cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -111,7 +111,7 @@ export namespace ESLintClient { | |||
|
||||
// Filters for client options | ||||
const packageJsonFilter: DocumentFilter = { scheme: 'file', pattern: '**/package.json' }; | ||||
const configFileFilter: DocumentFilter = { scheme: 'file', pattern: '**/.eslintr{c.js,c.yaml,c.yml,c,c.json}' }; | ||||
const configFileFilter: DocumentFilter = { scheme: 'file', pattern: '**/{.eslintr{c.js,c.yaml,c.yml,c,c.json},eslint.config.js}' }; | ||||
const supportedQuickFixKinds: Set<string> = new Set([CodeActionKind.Source.value, CodeActionKind.SourceFixAll.value, `${CodeActionKind.SourceFixAll.value}.eslint`, CodeActionKind.QuickFix.value]); | ||||
|
||||
// A map of documents synced to the server | ||||
|
@@ -394,6 +394,7 @@ export namespace ESLintClient { | |||
synchronize: { | ||||
fileEvents: [ | ||||
Workspace.createFileSystemWatcher('**/.eslintr{c.js,c.cjs,c.yaml,c.yml,c,c.json}'), | ||||
Workspace.createFileSystemWatcher('**/eslint.config.js'), | ||||
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. You will also need to add this file to this filter: vscode-eslint/client/src/client.ts Line 114 in e345da0
|
||||
Workspace.createFileSystemWatcher('**/.eslintignore'), | ||||
Workspace.createFileSystemWatcher('**/package.json') | ||||
] | ||||
|
@@ -604,6 +605,7 @@ export namespace ESLintClient { | |||
validate: Validate.off, | ||||
packageManager: config.get<PackageManagers>('packageManager', 'npm'), | ||||
useESLintClass: config.get<boolean>('useESLintClass', false), | ||||
experimentalUseFlatConfig: config.get<boolean>('experimentalUseFlatConfig', false), | ||||
codeActionOnSave: { | ||||
mode: CodeActionsOnSaveMode.all | ||||
}, | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,7 @@ | |
"extensionKind": [ | ||
"workspace" | ||
], | ||
"enabledApiProposals": [ | ||
], | ||
"enabledApiProposals": [], | ||
"main": "./client/out/extension", | ||
"capabilities": { | ||
"virtualWorkspaces": { | ||
|
@@ -182,6 +181,12 @@ | |
"default": false, | ||
"description": "Since version 7 ESLint offers a new API call ESLint. Use it even if the old CLIEngine is available. From version 8 on forward on ESLint class is available." | ||
}, | ||
"eslint.experimentalUseFlatConfig": { | ||
"scope": "resource", | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Enable support of experimental Flat Config (aka eslint.config.js, supported by ESLint version 8.21 or later)." | ||
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. As mentioned previously, I would remove the 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. You can dismiss this comment now that you've explained why we're using the |
||
}, | ||
"eslint.workingDirectories": { | ||
"scope": "resource", | ||
"type": "array", | ||
|
@@ -338,7 +343,8 @@ | |
"items": { | ||
"type": "string" | ||
} | ||
}, { | ||
}, | ||
{ | ||
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. Not too important, but unless you did this on purpose, you might have a formatter making changes here. 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. Sorry, I reverted the formatting changes. |
||
"type": "null" | ||
} | ||
], | ||
|
@@ -425,7 +431,8 @@ | |
"items": { | ||
"type": "string" | ||
} | ||
}, { | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
|
@@ -464,29 +471,29 @@ | |
"description": "Override the severity of one or more rules reported by this extension, regardless of the project's ESLint config. Use globs to apply default severities for multiple rules." | ||
}, | ||
"eslint.notebooks.rules.customizations": { | ||
"items": { | ||
"properties": { | ||
"severity": { | ||
"enum": [ | ||
"downgrade", | ||
"error", | ||
"info", | ||
"default", | ||
"upgrade", | ||
"warn", | ||
"off" | ||
], | ||
"type": "string" | ||
}, | ||
"rule": { | ||
"type": "string" | ||
} | ||
"items": { | ||
"properties": { | ||
"severity": { | ||
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. What's the change here? Did you replace tabs with spaces? |
||
"enum": [ | ||
"downgrade", | ||
"error", | ||
"info", | ||
"default", | ||
"upgrade", | ||
"warn", | ||
"off" | ||
], | ||
"type": "string" | ||
}, | ||
"type": "object" | ||
"rule": { | ||
"type": "string" | ||
} | ||
}, | ||
"scope": "resource", | ||
"type": "array", | ||
"description": "A special rules customization section for text cells in notebook documents." | ||
"type": "object" | ||
}, | ||
"scope": "resource", | ||
"type": "array", | ||
"description": "A special rules customization section for text cells in notebook documents." | ||
} | ||
} | ||
}, | ||
|
@@ -580,4 +587,4 @@ | |
"webpack-cli": "^4.10.0", | ||
"shelljs": "^0.8.5" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"eslint.enable": true, | ||
"eslint.run": "onType", | ||
"eslint.trace.server": { | ||
"verbosity": "messages", | ||
"format": "text" | ||
}, | ||
"files.autoSave": "off", | ||
"editor.formatOnSave": false, | ||
"[javascript]": { | ||
"editor.formatOnSave": false, | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
}, | ||
"eslint.format.enable": true, | ||
"eslint.onIgnoredFiles": "off", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": true, | ||
"source.fixAll.eslint": true | ||
}, | ||
"eslint.experimentalUseFlatConfig": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function bar() { | ||
if (foo) { | ||
foo++; | ||
} | ||
} | ||
|
||
function foo(x) { | ||
console.log(x); | ||
bar(); | ||
var x = 10; | ||
console.log(undef); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const globals = require('globals'); | ||
|
||
module.exports = [ | ||
"eslint:recommended", | ||
{ | ||
files: ["**/*.js"], | ||
languageOptions: { | ||
parserOptions: { | ||
sourceType: "module" | ||
}, | ||
globals: { | ||
...globals.browser, | ||
...globals.node, | ||
...globals.es6, | ||
...globals.commonjs | ||
} | ||
}, | ||
}, | ||
{ | ||
files: ["sub/*.js"], | ||
rules: { | ||
"no-undef": "warn", | ||
"no-console": "warn" | ||
} | ||
} | ||
] |
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.
To remain consistent with the
useESLintClass
setting, I would remove theexperimental
suffix here.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.
Sorry for confusing you, but I'd like to keep the name
experimental
because, unlikeuseESLintClass
, this config will be unnecessary in the future when Flat Config is considered stable. At that time the regularESLint
class will have the Flat Config support as described here. Then this config can be removed and users can use Flat Config without additional configuration.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 understand now. Thanks for explaining!