Repository navigation
Remove ESLint and use independent Oxlint rules #8211
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
Open
gonzaloriestra
wants to merge
10
commits into
gonzalo/oxlint-06-rule-coverage
from
gonzalo/oxlint-06-remove-eslint
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3712ff8
Remove ESLint and activate independent Oxlint rules
gonzaloriestra 4ec8298
Account for existing tools in the lint coverage audit
gonzaloriestra 3f65b2d
Preserve source and legacy suppressions during Oxlint migration
gonzaloriestra d9a3da0
Preserve generated GraphQL import spacing
gonzaloriestra e79f61e
Describe current lint behavior and remove migration commentary
gonzaloriestra e1facc1
Keep rebased upgrade tests and e2e lint compatible with Oxlint
gonzaloriestra fe54c89
Remove obsolete console suppressions with independent rules
gonzaloriestra 30f8746
Apply cli-kit lint overrides from the workspace root
gonzaloriestra fe2a6f2
Lint CLI entry scripts in package targets
gonzaloriestra 030ff58
Align rebased test suppressions with active lint rules
gonzaloriestra 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 hidden or 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,5 @@ | ||
| --- | ||
| '@shopify/eslint-plugin-cli': major | ||
| --- | ||
|
|
||
| Limit the bundled config to CLI custom rules and remove its shared ESLint dependency tree. | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "recommendations": ["esbenp.prettier-vscode","dbaeumer.vscode-eslint","nrwl.angular-console","vitest.explorer"] | ||
| "recommendations": ["esbenp.prettier-vscode", "oxc.oxc-vscode", "nrwl.angular-console", "vitest.explorer"] | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,113 @@ | ||
| import {existsSync, readFileSync, writeFileSync} from 'node:fs' | ||
| import {matchesGlob, resolve} from 'node:path' | ||
| import {execFileSync} from 'node:child_process' | ||
|
|
||
| const root = execFileSync('git', ['rev-parse', '--show-toplevel'], {encoding: 'utf8'}).trim() | ||
| const read = (file) => JSON.parse(readFileSync(resolve(root, file), 'utf8')) | ||
| const baseline = read('configurations/oxlint-baseline.json') | ||
| const mapping = read('configurations/oxlint-rule-mapping.json') | ||
| const config = read('oxlint.json') | ||
| const scripts = read('package.json').scripts | ||
| const formattingInputs = [...scripts.prettier.matchAll(/"([^"]+)"/g)].map((match) => match[1]) | ||
| const match = (file, patterns) => patterns?.some((pattern) => matchesGlob(file, pattern)) | ||
| const severity = (value) => { | ||
| const level = Array.isArray(value) ? value[0] : value | ||
| return {off: 0, allow: 0, warn: 1, error: 2, deny: 2}[level] ?? level | ||
| } | ||
|
|
||
| const stable = (value) => | ||
| JSON.stringify(value, (_, item) => | ||
| item && typeof item === 'object' && !Array.isArray(item) | ||
| ? Object.fromEntries(Object.entries(item).sort(([first], [second]) => first.localeCompare(second))) | ||
| : item, | ||
| ) | ||
|
|
||
| const missing = new Map() | ||
| const options = new Set() | ||
| const severities = new Set() | ||
| const unsupported = new Set() | ||
| const supported = new Set() | ||
| const partial = new Set() | ||
| const missingFormatting = [] | ||
| let filesCompared = 0 | ||
| const retiredFiles = [] | ||
| for (const group of baseline.configurations) { | ||
| const before = {...baseline.rules, ...group.rules} | ||
| for (const name of group.removed) delete before[name] | ||
| for (const file of group.files) { | ||
| if (!existsSync(resolve(root, file))) { | ||
| retiredFiles.push(file) | ||
| continue | ||
| } | ||
| const after = {...config.rules} | ||
| for (const override of config.overrides) { | ||
| if (match(file, override.files) && !match(file, override.excludeFiles)) Object.assign(after, override.rules) | ||
| } | ||
| // Preserve file-wide exemptions while comparing effective file scopes. | ||
| const header = | ||
| readFileSync(resolve(root, file), 'utf8').match(/^(?:\s*(?:\/\/[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/))*/)?.[0] ?? '' | ||
| for (const directive of header.matchAll(/eslint-disable(?!-)([^\n*]*)/g)) { | ||
| for (const name of directive[1] | ||
| .split(' -- ')[0] | ||
| .split(',') | ||
| .map((name) => name.trim())) | ||
| delete after[name] | ||
| } | ||
| if (!match(file, formattingInputs)) missingFormatting.push(file) | ||
| for (const [name, value] of Object.entries(before)) { | ||
| const replacement = mapping[name] | ||
| if (!replacement) throw new Error(`Undocumented original rule: ${name}`) | ||
| if (replacement.status === 'unsupported') { | ||
| unsupported.add(name) | ||
| continue | ||
| } | ||
| if (severity(after[replacement.replacement] ?? 'off') === 0) { | ||
| const examples = missing.get(name) ?? [] | ||
| if (examples.length < 4) examples.push(file) | ||
| missing.set(name, examples) | ||
| continue | ||
| } | ||
| supported.add(name) | ||
| if (replacement.status === 'partial') partial.add(name) | ||
| if (severity(value) !== severity(after[replacement.replacement])) severities.add(name) | ||
| const parameters = (configuration) => (Array.isArray(configuration) ? configuration.slice(1) : []) | ||
| if (stable(parameters(value)) !== stable(parameters(after[replacement.replacement]))) options.add(name) | ||
| } | ||
| filesCompared++ | ||
| } | ||
| } | ||
|
|
||
| // Other tools can cover only part of a rule or its file scope. | ||
| const otherToolCoverage = Object.fromEntries( | ||
| [...unsupported] | ||
| .filter((name) => mapping[name].otherToolCoverage) | ||
| .map((name) => [name, mapping[name].otherToolCoverage]), | ||
| ) | ||
|
|
||
| const summary = { | ||
| baselineCommit: baseline.baselineCommit, | ||
| filesCompared, | ||
| retiredFiles: retiredFiles.length, | ||
| baselineLintRules: Object.keys(mapping).length, | ||
| rulesWithReplacements: supported.size, | ||
| partialReplacements: partial.size, | ||
| rulesWithoutDedicatedReplacement: unsupported.size, | ||
| rulesWithOtherToolCoverage: Object.keys(otherToolCoverage).length, | ||
| rulesWithScopeGaps: missing.size, | ||
| optionDifferences: options.size, | ||
| severityDifferences: severities.size, | ||
| missingFormattingFiles: missingFormatting.length, | ||
| } | ||
| const findings = { | ||
| scopeGaps: Object.fromEntries(missing), | ||
| optionDifferences: [...options].sort(), | ||
| severityDifferences: [...severities].sort(), | ||
| rulesWithoutDedicatedReplacement: [...unsupported].sort(), | ||
| otherToolCoverage, | ||
| partialReplacements: [...partial].sort(), | ||
| missingFormatting, | ||
| } | ||
| const output = process.argv[2] ?? '/tmp/cli-oxlint-coverage-audit.json' | ||
| writeFileSync(output, JSON.stringify({summary, findings}, null, 2) + '\n') | ||
| console.log(JSON.stringify(summary, null, 2)) | ||
| if (missing.size || missingFormatting.length || severities.size) process.exitCode = 1 |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.