-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support ESLint v9 (Excluding flat config support) #341
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ed02a83
ues eslint@9.0.0-alpha.0
mizdra ddc0e84
run tests with eslint@9.0.0-alpha.0
mizdra c4874f8
add FlatESLint types
mizdra 19b7c37
add `shouldUseFlatConfig`
mizdra bf92a4a
add LegacyESLint type
mizdra f444445
use `LegacyESLint` instead of `ESLint`
mizdra ef1308d
warn against the use of flat config
mizdra 8cdc73b
use `new Linter({ configType: 'eslintrc' })` instead of `new Linter()`
mizdra 9a2e585
`shouldUseFlatConfig` is exported from `eslint/use-at-your-own-risk`
mizdra 15d72d8
fix ESM/CJS compatibility error
mizdra ba1ce5f
patch @types/eslint
mizdra 9a69165
Revert "ues eslint@9.0.0-alpha.0"
mizdra 884a402
fix lint error
mizdra 9fad185
prevent `^` from being treated as a special character on Windows
mizdra 93e44c9
do not use `^` for windows
mizdra cb33549
add `eslint@9.0.0-alpha.0"` to peerDependencies for test
mizdra c8a5220
use `ESLINT_USE_FLAT_CONFIG=false` in E2E tests
mizdra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
diff --git a/index.d.ts b/index.d.ts | ||
index 538c0dc1851122fbba808968e02100c9ca5728c4..d16f8776837a844f5e8be9b4053386e53d495ef5 100644 | ||
--- a/index.d.ts | ||
+++ b/index.d.ts | ||
@@ -842,7 +842,7 @@ export class Linter { | ||
|
||
version: string; | ||
|
||
- constructor(options?: { cwd?: string | undefined; configType?: "flat" }); | ||
+ constructor(options?: { cwd?: string | undefined; configType?: "flat" | "eslintrc" }); | ||
|
||
verify( | ||
code: SourceCode | string, | ||
diff --git a/use-at-your-own-risk.d.ts b/use-at-your-own-risk.d.ts | ||
index 089a657babec22d7bfa526d10d2950c77af041f3..31c56d1ed865fb11ba484efba01edc6ba7c57da9 100644 | ||
--- a/use-at-your-own-risk.d.ts | ||
+++ b/use-at-your-own-risk.d.ts | ||
@@ -1,6 +1,63 @@ | ||
+import { ESLint, Linter, Rule } from "eslint"; | ||
+ | ||
/** @deprecated */ | ||
export const builtinRules: Map<string, import("./index.js").Rule.RuleModule>; | ||
/** @deprecated */ | ||
+export namespace FlatESLint { | ||
+ interface Options { | ||
+ // File enumeration | ||
+ cwd?: string | undefined; | ||
+ errorOnUnmatchedPattern?: boolean | undefined; | ||
+ globInputPaths?: boolean | undefined; | ||
+ ignore?: boolean | undefined; | ||
+ | ||
+ // Linting | ||
+ allowInlineConfig?: boolean | undefined; | ||
+ baseConfig?: Linter.FlatConfig | Linter.FlatConfig[] | undefined; | ||
+ overrideConfig?: Linter.FlatConfig | Linter.FlatConfig[] | undefined; | ||
+ overrideConfigFile?: boolean | string | undefined; | ||
+ reportUnusedDisableDirectives?: Linter.StringSeverity | undefined; | ||
+ | ||
+ // Autofix | ||
+ fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined; | ||
+ fixTypes?: Rule.RuleMetaData['type'][] | undefined; | ||
+ | ||
+ // Cache-related | ||
+ cache?: boolean | undefined; | ||
+ cacheLocation?: string | undefined; | ||
+ cacheStrategy?: 'content' | 'metadata' | undefined; | ||
+ } | ||
+} | ||
+/** @deprecated */ | ||
+export class FlatESLint { | ||
+ constructor(options?: FlatESLint.Options); | ||
+ | ||
+ static get version(): string; | ||
+ | ||
+ static outputFixes(results: ESLint.LintResult[]): Promise<void>; | ||
+ | ||
+ static getErrorResults(results: ESLint.LintResult[]): ESLint.LintResult[]; | ||
+ | ||
+ getRulesMetaForResults(results: ESLint.LintResult[]): Record<string, Rule.RuleMetaData>; | ||
+ | ||
+ lintFiles(patterns: string | string[]): Promise<ESLint.LintResult[]>; | ||
+ | ||
+ lintText( | ||
+ code: string, | ||
+ options?: { filePath?: string | undefined; warnIgnored?: boolean | undefined }, | ||
+ ): Promise<ESLint.LintResult[]>; | ||
+ | ||
+ loadFormatter(name?: string): Promise<ESLint.Formatter>; | ||
+ | ||
+ calculateConfigForFile(filePath: string): Promise<Linter.FlatConfig | undefined>; | ||
+ | ||
+ findConfigFile(): Promise<string | undefined>; | ||
+ | ||
+ isPathIgnored(filePath: string): Promise<boolean>; | ||
+} | ||
+/** @deprecated */ | ||
+export function shouldUseFlatConfig(): Promise<boolean>; | ||
+/** @deprecated */ | ||
export class FileEnumerator { | ||
constructor( | ||
params?: { | ||
@@ -17,3 +74,7 @@ export class FileEnumerator { | ||
patternOrPatterns: string | string[], | ||
): IterableIterator<{ config: any; filePath: string; ignored: boolean }>; | ||
} | ||
+export { | ||
+ /** @deprecated */ | ||
+ ESLint as LegacyESLint | ||
+}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url'; | |
import { Worker } from 'node:worker_threads'; | ||
import { wrap } from 'comlink'; | ||
import nodeEndpoint from 'comlink/dist/esm/node-adapter.mjs'; | ||
import eslintPkg from 'eslint/use-at-your-own-risk'; | ||
import isInstalledGlobally from 'is-installed-globally'; | ||
import terminalLink from 'terminal-link'; | ||
import { warn } from '../cli/log.js'; | ||
|
@@ -11,6 +12,8 @@ import { translateCLIOptions } from '../config.js'; | |
import { SerializableCore } from '../core-worker.js'; | ||
import { lint, selectAction, selectRuleIds, checkResults, NextScene } from '../scene/index.js'; | ||
|
||
const { shouldUseFlatConfig } = eslintPkg; | ||
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. This is workaround for eslint/eslint#17954. |
||
|
||
export type Options = { | ||
argv: string[]; | ||
}; | ||
|
@@ -27,6 +30,10 @@ export async function run(options: Options) { | |
); | ||
} | ||
const parsedCLIOptions = parseArgv(options.argv); | ||
const usingFlatConfig = await shouldUseFlatConfig(); | ||
if (usingFlatConfig) { | ||
throw new Error('Flat Config is not yet supported.'); // TODO: support flat config | ||
} | ||
const config = translateCLIOptions(parsedCLIOptions, 'eslintrc'); // TODO: support flat config | ||
|
||
// Directly executing the Core API will hog the main thread and halt the spinner. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
TODO: Submit PR to DefinitelyTyped