Comparing version 9.6.0 to 9.7.0
@@ -23,3 +23,5 @@ /** | ||
/** @typedef {import("../../linter/vfile").VFile} VFile */ | ||
/** @typedef {import("@eslint/core").File} File */ | ||
/** @typedef {import("@eslint/core").Language} Language */ | ||
/** @typedef {import("@eslint/core").OkParseResult} OkParseResult */ | ||
@@ -60,2 +62,5 @@ //----------------------------------------------------------------------------- | ||
/** | ||
* @type {Language} | ||
*/ | ||
module.exports = { | ||
@@ -148,3 +153,3 @@ | ||
* Parses the given file into an AST. | ||
* @param {VFile} file The virtual file to parse. | ||
* @param {File} file The virtual file to parse. | ||
* @param {Object} options Additional options passed from ESLint. | ||
@@ -206,3 +211,3 @@ * @param {LanguageOptions} options.languageOptions The language options. | ||
// If the message includes a leading line number, strip it: | ||
const message = `Parsing error: ${ex.message.replace(/^line \d+:/iu, "").trim()}`; | ||
const message = ex.message.replace(/^line \d+:/iu, "").trim(); | ||
@@ -225,4 +230,4 @@ debug("%s\n%s", message, ex.stack); | ||
* Creates a new `SourceCode` object from the given information. | ||
* @param {VFile} file The virtual file to create a `SourceCode` object from. | ||
* @param {Object} parseResult The result returned from `parse()`. | ||
* @param {File} file The virtual file to create a `SourceCode` object from. | ||
* @param {OkParseResult} parseResult The result returned from `parse()`. | ||
* @param {Object} options Additional options passed from ESLint. | ||
@@ -229,0 +234,0 @@ * @param {LanguageOptions} options.languageOptions The language options. |
@@ -32,2 +32,6 @@ /** | ||
/** @typedef {import("eslint-scope").Variable} Variable */ | ||
/** @typedef {import("eslint-scope").Scope} Scope */ | ||
/** @typedef {import("@eslint/core").SourceCode} ISourceCode */ | ||
/** @typedef {import("@eslint/core").Directive} IDirective */ | ||
/** @typedef {import("@eslint/core").TraversalStep} ITraversalStep */ | ||
@@ -377,2 +381,3 @@ //------------------------------------------------------------------------------ | ||
* A class to represent a directive comment. | ||
* @implements {IDirective} | ||
*/ | ||
@@ -434,2 +439,3 @@ class Directive { | ||
* Represents parsed source code. | ||
* @implements {ISourceCode} | ||
*/ | ||
@@ -440,3 +446,3 @@ class SourceCode extends TokenStore { | ||
* The cache of steps that were taken while traversing the source code. | ||
* @type {Array<TraversalStep>} | ||
* @type {Array<ITraversalStep>} | ||
*/ | ||
@@ -845,3 +851,3 @@ #steps; | ||
* @param {ASTNode} currentNode The node to get the scope of | ||
* @returns {eslint-scope.Scope} The scope information for this node | ||
* @returns {Scope} The scope information for this node | ||
* @throws {TypeError} If the `currentNode` argument is missing. | ||
@@ -848,0 +854,0 @@ */ |
@@ -13,2 +13,5 @@ /** | ||
/** @typedef {import("../shared/types").LintMessage} LintMessage */ | ||
/** @typedef {import("@eslint/core").Language} Language */ | ||
/** @typedef {import("@eslint/core").Position} Position */ | ||
/** @typedef {import("@eslint/core").RulesConfig} RulesConfig */ | ||
@@ -28,4 +31,4 @@ //------------------------------------------------------------------------------ | ||
* Compares the locations of two objects in a source file | ||
* @param {{line: number, column: number}} itemA The first object | ||
* @param {{line: number, column: number}} itemB The second object | ||
* @param {Position} itemA The first object | ||
* @param {Position} itemB The second object | ||
* @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if | ||
@@ -423,3 +426,3 @@ * itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location. | ||
* @param {"off" | "warn" | "error"} options.reportUnusedDisableDirectives If `"warn"` or `"error"`, adds additional problems for unused directives | ||
* @param {Object} options.configuredRules The rules configuration. | ||
* @param {RulesConfig} options.configuredRules The rules configuration. | ||
* @param {Function} options.ruleFilter A predicate function to filter which rules should be executed. | ||
@@ -426,0 +429,0 @@ * @param {boolean} options.disableFixes If true, it doesn't make `fix` properties. |
@@ -337,6 +337,4 @@ /** | ||
enterNode(node) { | ||
if (node.parent) { | ||
this.currentAncestry.unshift(node.parent); | ||
} | ||
this.applySelectors(node, false); | ||
this.currentAncestry.unshift(node); | ||
} | ||
@@ -350,4 +348,4 @@ | ||
leaveNode(node) { | ||
this.currentAncestry.shift(); | ||
this.applySelectors(node, true); | ||
this.currentAncestry.shift(); | ||
} | ||
@@ -354,0 +352,0 @@ } |
@@ -8,2 +8,8 @@ /** | ||
//----------------------------------------------------------------------------- | ||
// Type Definitions | ||
//----------------------------------------------------------------------------- | ||
/** @typedef {import("@eslint/core").File} File */ | ||
//------------------------------------------------------------------------------ | ||
@@ -58,2 +64,3 @@ // Helpers | ||
* Represents a virtual file inside of ESLint. | ||
* @implements {File} | ||
*/ | ||
@@ -60,0 +67,0 @@ class VFile { |
@@ -92,2 +92,5 @@ /** | ||
}, | ||
regex: { | ||
type: "string" | ||
}, | ||
importNamePattern: { | ||
@@ -108,3 +111,2 @@ type: "string" | ||
additionalProperties: false, | ||
required: ["group"], | ||
not: { | ||
@@ -118,3 +120,7 @@ anyOf: [ | ||
] | ||
} | ||
}, | ||
oneOf: [ | ||
{ required: ["group"] }, | ||
{ required: ["regex"] } | ||
] | ||
}, | ||
@@ -241,5 +247,6 @@ uniqueItems: true | ||
const restrictedPatternGroups = restrictedPatterns.map( | ||
({ group, message, caseSensitive, importNames, importNamePattern, allowImportNames, allowImportNamePattern }) => ( | ||
({ group, regex, message, caseSensitive, importNames, importNamePattern, allowImportNames, allowImportNamePattern }) => ( | ||
{ | ||
matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group), | ||
...(group ? { matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group) } : {}), | ||
...(typeof regex === "string" ? { regexMatcher: new RegExp(regex, caseSensitive ? "u" : "iu") } : {}), | ||
customMessage: message, | ||
@@ -500,3 +507,3 @@ importNames, | ||
function isRestrictedPattern(importSource, group) { | ||
return group.matcher.ignores(importSource); | ||
return group.regexMatcher ? group.regexMatcher.test(importSource) : group.matcher.ignores(importSource); | ||
} | ||
@@ -503,0 +510,0 @@ |
@@ -343,3 +343,3 @@ /** | ||
* @param {Variable} variable eslint-scope variable object. | ||
* @returns {boolean} True if the variable is exported, false if not. | ||
* @returns {boolean} True if the variable has a sibling rest property, false if not. | ||
* @private | ||
@@ -346,0 +346,0 @@ */ |
@@ -75,7 +75,7 @@ /** | ||
messages: { | ||
nested: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' from within that group.", | ||
forward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears later in the pattern.", | ||
backward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears before in the same lookbehind.", | ||
disjunctive: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in another alternative.", | ||
intoNegativeLookaround: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in a negative lookaround." | ||
nested: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} from within that group.", | ||
forward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which appears later in the pattern.", | ||
backward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which appears before in the same lookbehind.", | ||
disjunctive: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which is in another alternative.", | ||
intoNegativeLookaround: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which is in a negative lookaround." | ||
} | ||
@@ -108,13 +108,18 @@ }, | ||
onBackreferenceEnter(bref) { | ||
const group = bref.resolved, | ||
brefPath = getPathToRoot(bref), | ||
groupPath = getPathToRoot(group); | ||
let messageId = null; | ||
const groups = [bref.resolved].flat(), | ||
brefPath = getPathToRoot(bref); | ||
if (brefPath.includes(group)) { | ||
const problems = groups.map(group => { | ||
const groupPath = getPathToRoot(group); | ||
// group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match. | ||
messageId = "nested"; | ||
} else { | ||
if (brefPath.includes(group)) { | ||
// group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match. | ||
return { | ||
messageId: "nested", | ||
group | ||
}; | ||
} | ||
// Start from the root to find the lowest common ancestor. | ||
@@ -135,31 +140,76 @@ let i = brefPath.length - 1, | ||
if (groupCut.at(-1).type === "Alternative") { | ||
// group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive. | ||
return { | ||
messageId: "disjunctive", | ||
group | ||
}; | ||
} | ||
if (!isMatchingBackward && bref.end <= group.start) { | ||
// bref is left, group is right ('forward reference') => group hasn't matched yet when bref starts to match. | ||
messageId = "forward"; | ||
} else if (isMatchingBackward && group.end <= bref.start) { | ||
return { | ||
messageId: "forward", | ||
group | ||
}; | ||
} | ||
if (isMatchingBackward && group.end <= bref.start) { | ||
// the opposite of the previous when the regex is matching backward in a lookbehind context. | ||
messageId = "backward"; | ||
} else if (groupCut.at(-1).type === "Alternative") { | ||
return { | ||
messageId: "backward", | ||
group | ||
}; | ||
} | ||
if (groupCut.some(isNegativeLookaround)) { | ||
// group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive. | ||
messageId = "disjunctive"; | ||
} else if (groupCut.some(isNegativeLookaround)) { | ||
// group is in a negative lookaround which isn't bref's ancestor => group has already failed when bref starts to match. | ||
messageId = "intoNegativeLookaround"; | ||
return { | ||
messageId: "intoNegativeLookaround", | ||
group | ||
}; | ||
} | ||
return null; | ||
}); | ||
if (problems.length === 0 || problems.some(problem => !problem)) { | ||
// If there are no problems or no problems with any group then do not report it. | ||
return; | ||
} | ||
if (messageId) { | ||
context.report({ | ||
node, | ||
messageId, | ||
data: { | ||
bref: bref.raw, | ||
group: group.raw | ||
} | ||
}); | ||
let problemsToReport; | ||
// Gets problems that appear in the same disjunction. | ||
const problemsInSameDisjunction = problems.filter(problem => problem.messageId !== "disjunctive"); | ||
if (problemsInSameDisjunction.length) { | ||
// Only report problems that appear in the same disjunction. | ||
problemsToReport = problemsInSameDisjunction; | ||
} else { | ||
// If all groups appear in different disjunctions, report it. | ||
problemsToReport = problems; | ||
} | ||
const [{ messageId, group }, ...other] = problemsToReport; | ||
let otherGroups = ""; | ||
if (other.length === 1) { | ||
otherGroups = " and another group"; | ||
} else if (other.length > 1) { | ||
otherGroups = ` and other ${other.length} groups`; | ||
} | ||
context.report({ | ||
node, | ||
messageId, | ||
data: { | ||
bref: bref.raw, | ||
group: group.raw, | ||
otherGroups | ||
} | ||
}); | ||
} | ||
@@ -166,0 +216,0 @@ }); |
@@ -11,3 +11,3 @@ /** | ||
const REGEXPP_LATEST_ECMA_VERSION = 2024; | ||
const REGEXPP_LATEST_ECMA_VERSION = 2025; | ||
@@ -14,0 +14,0 @@ /** |
{ | ||
"name": "eslint", | ||
"version": "9.6.0", | ||
"version": "9.7.0", | ||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>", | ||
@@ -70,6 +70,6 @@ "description": "An AST-based pattern checker for JavaScript.", | ||
"@eslint-community/eslint-utils": "^4.2.0", | ||
"@eslint-community/regexpp": "^4.6.1", | ||
"@eslint-community/regexpp": "^4.11.0", | ||
"@eslint/config-array": "^0.17.0", | ||
"@eslint/eslintrc": "^3.1.0", | ||
"@eslint/js": "9.6.0", | ||
"@eslint/js": "9.7.0", | ||
"@humanwhocodes/module-importer": "^1.0.1", | ||
@@ -83,3 +83,3 @@ "@humanwhocodes/retry": "^0.3.0", | ||
"escape-string-regexp": "^4.0.0", | ||
"eslint-scope": "^8.0.1", | ||
"eslint-scope": "^8.0.2", | ||
"eslint-visitor-keys": "^4.0.0", | ||
@@ -109,2 +109,3 @@ "espree": "^10.1.0", | ||
"@babel/preset-env": "^7.4.3", | ||
"@eslint/core": "^0.1.0", | ||
"@types/estree": "^1.0.5", | ||
@@ -111,0 +112,0 @@ "@types/node": "^20.11.5", |
@@ -42,3 +42,3 @@ [![npm version](https://img.shields.io/npm/v/eslint.svg)](https://www.npmjs.com/package/eslint) | ||
12. [Sponsors](#sponsors) | ||
13. [Technology Sponsors](#technology-sponsors) | ||
13. [Technology Sponsors](#technology-sponsors) <!-- markdownlint-disable-line MD051 --> | ||
@@ -298,3 +298,3 @@ ## Installation and Usage | ||
<h3>Platinum Sponsors</h3> | ||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="undefined"></a></p><h3>Gold Sponsors</h3> | ||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3> | ||
<p><a href="#"><img src="https://images.opencollective.com/guest-bf377e88/avatar.png" alt="Eli Schleifer" height="96"></a> <a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a></p><h3>Silver Sponsors</h3> | ||
@@ -305,6 +305,5 @@ <p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3> | ||
## Technology Sponsors | ||
* Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com) | ||
* Hosting for ([eslint.org](https://eslint.org)) is sponsored by [Netlify](https://www.netlify.com) | ||
* Password management is sponsored by [1Password](https://www.1password.com) | ||
<!--techsponsorsstart--> | ||
<h2>Technology Sponsors</h2> | ||
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p> | ||
<!--techsponsorsend--> |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3071366
72306
61
306
+ Added@eslint/js@9.7.0(transitive)
- Removed@eslint/js@9.6.0(transitive)
Updated@eslint/js@9.7.0
Updatedeslint-scope@^8.0.2