JS-483 Filter rules by detected ES version#6573
Merged
Conversation
…n signals Rules tagged with an ES version in RSPEC (e.g. es2022) are now automatically disabled when the project's detected ES version is lower than required. - tools/generate-eslint-meta.ts: extract es20XX tag from RSPEC, emit requiredEcmaVersion field in generated-meta.ts - tools/templates/ts/generated-meta.template: add requiredEcmaVersion export - Regenerate all generated-meta.ts files (~60 rules now carry the field) - options.ts: add esLibToYear() helper to extract ES year from normalized lib - analyzeWithProgram.ts / analyzeWithIncrementalProgram.ts: extract detectedEsYear from program lib after program creation, thread it down - analyzeFile.ts / analysis.ts / analyzer.ts: propagate detectedEsYear - linter.ts: filter rules by requiredEcmaVersion in getRulesForFile(), include detectedEsYear in rules cache key Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- options.test.ts: tests for esLibToYear covering normal years, esnext, undefined, and empty lib arrays - linter/index.test.ts: tests for getRulesForFile ES version filtering using S7755 (requiredEcmaVersion=2022) — disabled below ES2022, enabled at ES2022, and enabled when no year detected (esnext fallback) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
Two bugs: 1. Returned the first 4-digit year match instead of the maximum. User tsconfigs can list multiple years (e.g. ['es2015','es2017','es2019']); the effective ES level is the highest one. 2. When a merged program contains both a year lib and esnext (e.g. [es2020, esnext]), returned the year instead of null. esnext means no ES version restriction regardless of other entries. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
vdiez
approved these changes
Mar 16, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.




Summary
es2022) are now automatically disabled when the project's detected ES version is lower than requiredcomputeLibJson(target + package.json signals)requiredEcmaVersionfield in their generated metadataChanges
tools/generate-eslint-meta.ts+ template: extractes20XXtag from RSPEC, emitrequiredEcmaVersionin everygenerated-meta.tsoptions.ts: addesLibToYear()helper to read ES year from normalized lib filenamesanalyzeWithProgram.ts/analyzeWithIncrementalProgram.ts: extractdetectedEsYearafter program creation and thread it down the call chainanalyzeFile.ts/analysis.ts/analyzer.ts: propagatedetectedEsYearas optional fieldlinter.ts: filter rules byrequiredEcmaVersioningetRulesForFile(), includedetectedEsYearin rules cache keyTest plan
es2022(e.g. S7755prefer-at) are disabled for projects detected as ES2020 or loweres2015are disabled for projects with no ES signals (falls back to esnext → all rules enabled)detectedEsYearis null (esnext fallback or no program), all rules remain enabled🤖 Generated with Claude Code