From a41a8e4a7da14726d6fce71a023f12101fd52fdb Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 30 Jul 2023 02:39:43 +0530 Subject: [PATCH 01/17] docs: update script names in README (#17432) --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 33f91bd3f731..026430cc0d26 100644 --- a/docs/README.md +++ b/docs/README.md @@ -25,19 +25,19 @@ Once the script finishes building the documentation site, you can visit it at To update the links data file, run this from the root folder (not the `docs` folder): ```shell -npm run docs:update-links +npm run build:docs:update-links ``` To lint JS files, run this from the root folder (not the `docs` folder): ```shell -npm run lint:docsjs +npm run lint:docs:js ``` To autofix JS files, run this from the root folder (not the `docs` folder): ```shell -npm run fix:docsjs +npm run lint:fix:docs:js ``` ## License From 224376cd99a08394291a9584ad9c1ea1283673c6 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Tue, 1 Aug 2023 08:06:53 +0000 Subject: [PATCH 02/17] docs: Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e16c09bb9867..7184ed7aadc8 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ The following companies, organizations, and individuals support ESLint's ongoing

Chrome Frameworks Fund Automattic

Gold Sponsors

Salesforce Airbnb

Silver Sponsors

Sentry Liftoff American Express

Bronze Sponsors

-

ThemeIsle Nx (by Nrwl) Anagram Solver Icons8: free icons, photos, illustrations, and music Discord iBoysoft BairesDev GitHub Transloadit Ignition HeroCoders QuickBooks Tool hub

+

ThemeIsle Nx (by Nrwl) Anagram Solver Icons8: free icons, photos, illustrations, and music Discord iBoysoft GitHub Transloadit Ignition HeroCoders QuickBooks Tool hub

## Technology Sponsors From d743ed3c06c62a639da0389ad27907b324ea1715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 1 Aug 2023 12:21:00 -0400 Subject: [PATCH 03/17] docs: add metadata for parser/processor (#17438) * docs: add metadata for parser/processor * Update docs/src/extend/custom-parsers.md Co-authored-by: Nicholas C. Zakas * review comments * rearrange `meta` object after `postprocess` --------- Co-authored-by: Nicholas C. Zakas --- docs/src/extend/custom-parsers.md | 22 ++++++++++- docs/src/extend/custom-processors.md | 6 +++ docs/src/extend/plugins.md | 56 ++++++++++++++-------------- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/docs/src/extend/custom-parsers.md b/docs/src/extend/custom-parsers.md index a7327fb91f60..55ed726f046c 100644 --- a/docs/src/extend/custom-parsers.md +++ b/docs/src/extend/custom-parsers.md @@ -12,6 +12,8 @@ ESLint custom parsers let you extend ESLint to support linting new non-standard ## Creating a Custom Parser +### Methods in Custom Parsers + A custom parser is a JavaScript object with either a `parse` or `parseForESLint` method. The `parse` method only returns the AST, whereas `parseForESLint` also returns additional values that let the parser customize the behavior of ESLint even more. Both methods should take in the source code as the first argument, and an optional configuration object as the second argument, which is provided as [`parserOptions`](../use/configure/language-options#specifying-parser-options) in a configuration file. @@ -33,11 +35,11 @@ function parse(code, options) { module.exports = { parse }; ``` -## `parse` Return Object +### `parse` Return Object The `parse` method should simply return the [AST](#ast-specification) object. -## `parseForESLint` Return Object +### `parseForESLint` Return Object The `parseForESLint` method should return an object that contains the required property `ast` and optional properties `services`, `scopeManager`, and `visitorKeys`. @@ -48,6 +50,22 @@ The `parseForESLint` method should return an object that contains the required p * `visitorKeys` can be an object to customize AST traversal. The keys of the object are the type of AST nodes. Each value is an array of the property names which should be traversed. The default is [KEYS of `eslint-visitor-keys`](https://github.com/eslint/eslint-visitor-keys#evkkeys). * Support for `visitorKeys` was added in ESLint v4.14.0. ESLint versions that support `visitorKeys` will provide an `eslintVisitorKeys: true` property in `parserOptions`, which can be used for feature detection. +### Meta Data in Custom Parsers + +For easier debugging and more effective caching of custom parsers, it's recommended to provide a name and version in a `meta` object at the root of your custom parsers, like this: + +```js +// preferred location of name and version +module.exports = { + meta: { + name: "eslint-parser-custom", + version: "1.2.3" + } +}; +``` + +The `meta.name` property should match the npm package name for your custom parser and the `meta.version` property should match the npm package version for your custom parser. The easiest way to accomplish this is by reading this information from your `package.json`. + ## AST Specification The AST that custom parsers should create is based on [ESTree](https://github.com/estree/estree). The AST requires some additional properties about detail information of the source code. diff --git a/docs/src/extend/custom-processors.md b/docs/src/extend/custom-processors.md index a47271e2e9e6..d5a5261d9769 100644 --- a/docs/src/extend/custom-processors.md +++ b/docs/src/extend/custom-processors.md @@ -18,6 +18,10 @@ In order to create a custom processor, the object exported from your module has module.exports = { processors: { "processor-name": { + meta: { + name: "eslint-processor-name", + version: "1.2.3" + }, // takes text of the file and filename preprocess: function(text, filename) { // here, you can strip out any non-JS content @@ -121,6 +125,8 @@ By default, ESLint does not perform autofixes when a custom processor is used, e You can have both rules and custom processors in a single plugin. You can also have multiple processors in one plugin. To support multiple extensions, add each one to the `processors` element and point them to the same object. +**The `meta` object** helps ESLint cache the processor and provide more friendly debug message. The `meta.name` property should match the processor name and the `meta.version` property should match the npm package version for your processors. The easiest way to accomplish this is by reading this information from your `package.json`. + ## Specifying Processor in Config Files To use a processor, add its ID to a `processor` section in the config file. Processor ID is a concatenated string of plugin name and processor name with a slash as a separator. This can also be added to a `overrides` section of the config, to specify which processors should handle which files. diff --git a/docs/src/extend/plugins.md b/docs/src/extend/plugins.md index 82e8fd8f1170..5374a0f50946 100644 --- a/docs/src/extend/plugins.md +++ b/docs/src/extend/plugins.md @@ -18,34 +18,6 @@ Each plugin is an npm module with a name in the format of `eslint-plugin- Date: Wed, 2 Aug 2023 13:04:08 +0900 Subject: [PATCH 04/17] docs: update with "Specifying Parser Options" (#17435) * docs: update with "Specifying Parser Options" * docs : reapply lint * Update docs/src/use/configure/language-options.md * docs : reapply lint --------- Co-authored-by: Francesco Trotta --- docs/src/use/configure/language-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/use/configure/language-options.md b/docs/src/use/configure/language-options.md index a89224780ac3..4bcd63e3c98f 100644 --- a/docs/src/use/configure/language-options.md +++ b/docs/src/use/configure/language-options.md @@ -191,7 +191,7 @@ ESLint allows you to specify the JavaScript language options you want to support Please note that supporting JSX syntax is not the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) if you are using React. -By the same token, supporting ES6 syntax is not the same as supporting new ES6 globals (e.g., new types such as `Set`). For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 global variables, use `{ "env": { "es6": true } }`. Setting `{ "env": { "es6": true } }` enables ES6 syntax automatically, but `{ "parserOptions": { "ecmaVersion": 6 } }` does not enable ES6 globals automatically. +By the same token, supporting ES6 syntax is not the same as supporting new ES6 globals (e.g., new types such as `Set`). For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 global variables, use `{ "env": { "es6": true } }`. Setting `{ "env": { "es6": true } }` enables ES6 syntax automatically, but `{ "parserOptions": { "ecmaVersion": 6 } }` does not enable ES6 globals automatically. In summary, to support only ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`, and to support both ES6 syntax and new ES6 global variables, such as `Set` and others, use `{ "env": { "es6": true } }`. Parser options are set in your `.eslintrc.*` file with the `parserOptions` property. The available options are: From fcdc85d3a6bc14970c3349cc8d6f3a47eca172a3 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Wed, 2 Aug 2023 08:06:23 +0000 Subject: [PATCH 05/17] docs: Update README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7184ed7aadc8..bf686b31b180 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,11 @@ Bryan Mishkin
Francesco Trotta + + +
+Yosuke Ota +
### Website Team From 53d750800b1c0c1f8c29393c488bb3167bb1d2a5 Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Wed, 2 Aug 2023 16:52:21 +0200 Subject: [PATCH 06/17] feat: update regex for methods with `thisArg` (#17439) * feat: update regex for methods with `thisArg` * rename regex constant --- lib/rules/utils/ast-utils.js | 8 +-- tests/lib/rules/no-eval.js | 24 +++++++ tests/lib/rules/no-invalid-this.js | 112 ++++++++--------------------- 3 files changed, 56 insertions(+), 88 deletions(-) diff --git a/lib/rules/utils/ast-utils.js b/lib/rules/utils/ast-utils.js index 08a23c888786..bebb4d5168b3 100644 --- a/lib/rules/utils/ast-utils.js +++ b/lib/rules/utils/ast-utils.js @@ -26,8 +26,8 @@ const { const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u; const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u; +const arrayMethodWithThisArgPattern = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|some)$/u; const arrayOrTypedArrayPattern = /Array$/u; -const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u; const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u; const thisTagPattern = /^[\s*]*@this/mu; @@ -467,12 +467,12 @@ function isArrayFromMethod(node) { } /** - * Checks whether or not a node is a method which has `thisArg`. + * Checks whether or not a node is a method which expects a function as a first argument, and `thisArg` as a second argument. * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a method which has `thisArg`. + * @returns {boolean} Whether or not the node is a method which expects a function as a first argument, and `thisArg` as a second argument. */ function isMethodWhichHasThisArg(node) { - return isSpecificMemberAccess(node, null, arrayMethodPattern); + return isSpecificMemberAccess(node, null, arrayMethodWithThisArgPattern); } /** diff --git a/tests/lib/rules/no-eval.js b/tests/lib/rules/no-eval.js index 840bcb20f1de..de1e11df19ed 100644 --- a/tests/lib/rules/no-eval.js +++ b/tests/lib/rules/no-eval.js @@ -57,6 +57,11 @@ ruleTester.run("no-eval", rule, { { code: "class A { field = () => this.eval(); }", parserOptions: { ecmaVersion: 2022 } }, { code: "class A { static { this.eval(); } }", parserOptions: { ecmaVersion: 2022 } }, + // User-defined this.eval in callbacks + "array.findLast(function (x) { return this.eval.includes(x); }, { eval: ['foo', 'bar'] });", + "callbacks.findLastIndex(function (cb) { return cb(this.eval); }, this);", + "['1+1'].flatMap(function (str) { return this.eval(str); }, new Evaluator);", + // Allows indirect eval { code: "(0, eval)('foo')", options: [{ allowIndirect: true }] }, { code: "(0, window.eval)('foo')", options: [{ allowIndirect: true }], env: { browser: true } }, @@ -162,6 +167,25 @@ ruleTester.run("no-eval", rule, { code: "function foo() { 'use strict'; this.eval(); }", parserOptions: { ecmaVersion: 3 }, errors: [{ messageId: "unexpected" }] + }, + + // this.eval in callbacks (not user-defined) + { + code: "array.findLast(x => this.eval.includes(x), { eval: 'abc' });", + parserOptions: { ecmaVersion: 2023 }, + errors: [{ messageId: "unexpected" }] + }, + { + code: "callbacks.findLastIndex(function (cb) { return cb(eval); }, this);", + errors: [{ messageId: "unexpected" }] + }, + { + code: "['1+1'].flatMap(function (str) { return this.eval(str); });", + errors: [{ messageId: "unexpected" }] + }, + { + code: "['1'].reduce(function (a, b) { return this.eval(a) ? a : b; }, '0');", + errors: [{ messageId: "unexpected" }] } ] }); diff --git a/tests/lib/rules/no-invalid-this.js b/tests/lib/rules/no-invalid-this.js index dd72be499915..7e8d4776d9bc 100644 --- a/tests/lib/rules/no-invalid-this.js +++ b/tests/lib/rules/no-invalid-this.js @@ -474,103 +474,47 @@ const patterns = [ valid: [NORMAL], invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] }, - { - code: "foo.every(function() { console.log(this); z(x => console.log(x, this)); });", - parserOptions: { ecmaVersion: 6 }, - errors, - valid: [NORMAL], - invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, - { - code: "foo.filter(function() { console.log(this); z(x => console.log(x, this)); });", - parserOptions: { ecmaVersion: 6 }, - errors, - valid: [NORMAL], - invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, - { - code: "foo.find(function() { console.log(this); z(x => console.log(x, this)); });", - parserOptions: { ecmaVersion: 6 }, - errors, - valid: [NORMAL], - invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, - { - code: "foo.findIndex(function() { console.log(this); z(x => console.log(x, this)); });", - parserOptions: { ecmaVersion: 6 }, - errors, - valid: [NORMAL], - invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, - { - code: "foo.forEach(function() { console.log(this); z(x => console.log(x, this)); });", - parserOptions: { ecmaVersion: 6 }, - errors, - valid: [NORMAL], - invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, - { - code: "foo.map(function() { console.log(this); z(x => console.log(x, this)); });", - parserOptions: { ecmaVersion: 6 }, - errors, - valid: [NORMAL], - invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, - { - code: "foo.some(function() { console.log(this); z(x => console.log(x, this)); });", + ...[ + "every", + "filter", + "find", + "findIndex", + "findLast", + "findLastIndex", + "flatMap", + "forEach", + "map", + "some" + ].map(methodName => ({ + code: `foo.${methodName}(function() { console.log(this); z(x => console.log(x, this)); });`, parserOptions: { ecmaVersion: 6 }, errors, valid: [NORMAL], invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] - }, + })), { code: "Array.from([], function() { console.log(this); z(x => console.log(x, this)); }, obj);", parserOptions: { ecmaVersion: 6 }, valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], invalid: [] }, - { - code: "foo.every(function() { console.log(this); z(x => console.log(x, this)); }, obj);", - parserOptions: { ecmaVersion: 6 }, - valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], - invalid: [] - }, - { - code: "foo.filter(function() { console.log(this); z(x => console.log(x, this)); }, obj);", - parserOptions: { ecmaVersion: 6 }, - valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], - invalid: [] - }, - { - code: "foo.find(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + ...[ + "every", + "filter", + "find", + "findIndex", + "findLast", + "findLastIndex", + "flatMap", + "forEach", + "map", + "some" + ].map(methodName => ({ + code: `foo.${methodName}(function() { console.log(this); z(x => console.log(x, this)); }, obj);`, parserOptions: { ecmaVersion: 6 }, valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], invalid: [] - }, - { - code: "foo.findIndex(function() { console.log(this); z(x => console.log(x, this)); }, obj);", - parserOptions: { ecmaVersion: 6 }, - valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], - invalid: [] - }, - { - code: "foo.forEach(function() { console.log(this); z(x => console.log(x, this)); }, obj);", - parserOptions: { ecmaVersion: 6 }, - valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], - invalid: [] - }, - { - code: "foo.map(function() { console.log(this); z(x => console.log(x, this)); }, obj);", - parserOptions: { ecmaVersion: 6 }, - valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], - invalid: [] - }, - { - code: "foo.some(function() { console.log(this); z(x => console.log(x, this)); }, obj);", - parserOptions: { ecmaVersion: 6 }, - valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], - invalid: [] - }, + })), { code: "foo.forEach(function() { console.log(this); z(x => console.log(x, this)); }, null);", parserOptions: { ecmaVersion: 6 }, From 47a08597966651975126dd6726939cd34f13b80e Mon Sep 17 00:00:00 2001 From: SUZUKI Sosuke Date: Thu, 3 Aug 2023 00:03:48 +0900 Subject: [PATCH 07/17] docs: update `require-unicode-regexp.md` as following up #17402 (#17441) * docs: add `further_reading` links * docs: mention about `v` * Update docs/src/rules/require-unicode-regexp.md --------- Co-authored-by: Nicholas C. Zakas --- docs/src/_data/further_reading_links.json | 14 ++++++++++++++ docs/src/rules/require-unicode-regexp.md | 9 +++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/src/_data/further_reading_links.json b/docs/src/_data/further_reading_links.json index e66ef76ce696..045bd4faf628 100644 --- a/docs/src/_data/further_reading_links.json +++ b/docs/src/_data/further_reading_links.json @@ -726,5 +726,19 @@ "logo": "https://v8.dev/favicon.ico", "title": "Faster async functions and promises · V8", "description": "Faster and easier-to-debug async functions and promises are coming to V8 v7.2 / Chrome 72." + }, + "https://github.com/tc39/proposal-regexp-v-flag": { + "domain": "github.com", + "url": "https://github.com/tc39/proposal-regexp-v-flag", + "logo": "https://github.com/fluidicon.png", + "title": "GitHub - tc39/proposal-regexp-v-flag: UTS18 set notation in regular expressions", + "description": "UTS18 set notation in regular expressions. Contribute to tc39/proposal-regexp-v-flag development by creating an account on GitHub." + }, + "https://v8.dev/features/regexp-v-flag": { + "domain": "v8.dev", + "url": "https://v8.dev/features/regexp-v-flag", + "logo": "https://v8.dev/favicon.ico", + "title": "RegExp v flag with set notation and properties of strings · V8", + "description": "The new RegExp `v` flag enables `unicodeSets` mode, unlocking support for extended character classes, including Unicode properties of strings, set notation, and improved case-insensitive matching." } } \ No newline at end of file diff --git a/docs/src/rules/require-unicode-regexp.md b/docs/src/rules/require-unicode-regexp.md index 969818e2c0d9..d0069de15963 100644 --- a/docs/src/rules/require-unicode-regexp.md +++ b/docs/src/rules/require-unicode-regexp.md @@ -1,6 +1,9 @@ --- title: require-unicode-regexp rule_type: suggestion +further_reading: +- https://github.com/tc39/proposal-regexp-v-flag +- https://v8.dev/features/regexp-v-flag --- @@ -49,13 +52,11 @@ The RegExp `v` flag, introduced in ECMAScript 2024, is a superset of the `u` fla re.test('\u2028'); // → false ``` -Please see and for more details. - Therefore, the `u` and `v` flags let us work better with regular expressions. ## Rule Details -This rule aims to enforce the use of `u` flag on regular expressions. +This rule aims to enforce the use of `u` or `v` flag on regular expressions. Examples of **incorrect** code for this rule: @@ -99,4 +100,4 @@ function f(flags) { ## When Not To Use It -If you don't want to notify regular expressions with no `u` flag, then it's safe to disable this rule. +If you don't want to warn on regular expressions without either a `u` or a `v` flag, then it's safe to disable this rule. From 6b2410f911dd2e3d915c879041c6e257d41a2f4e Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 2 Aug 2023 11:53:19 -0400 Subject: [PATCH 08/17] chore: Update add-to-triage.yml (#17444) --- .github/workflows/add-to-triage.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/add-to-triage.yml b/.github/workflows/add-to-triage.yml index 64ef0397e17c..83297dcab333 100644 --- a/.github/workflows/add-to-triage.yml +++ b/.github/workflows/add-to-triage.yml @@ -4,9 +4,6 @@ on: issues: types: - opened - pull_request: - types: - - opened jobs: add-to-project: From a1635d6198a8baf6571b3351e098e5ac960be887 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Thu, 3 Aug 2023 08:06:22 +0000 Subject: [PATCH 09/17] docs: Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf686b31b180..0ce3a4a5a832 100644 --- a/README.md +++ b/README.md @@ -289,7 +289,7 @@ The following companies, organizations, and individuals support ESLint's ongoing

Chrome Frameworks Fund Automattic

Gold Sponsors

Salesforce Airbnb

Silver Sponsors

Sentry Liftoff American Express

Bronze Sponsors

-

ThemeIsle Nx (by Nrwl) Anagram Solver Icons8: free icons, photos, illustrations, and music Discord iBoysoft GitHub Transloadit Ignition HeroCoders QuickBooks Tool hub

+

ThemeIsle Nx (by Nrwl) Anagram Solver Icons8: free icons, photos, illustrations, and music Discord GitHub Transloadit Ignition HeroCoders QuickBooks Tool hub

## Technology Sponsors From a766a48030d4359db76523d5b413d6332130e485 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 4 Aug 2023 10:50:11 -0400 Subject: [PATCH 10/17] docs: document lack of config file names (#17442) * docs: document lack of config file names * Update configuration-files-new.md * Update docs/src/use/configure/configuration-files-new.md Co-authored-by: Nicholas C. Zakas --------- Co-authored-by: Nicholas C. Zakas --- docs/src/use/configure/configuration-files-new.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index 4c2bd1fa4df1..7903854f0622 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -58,6 +58,10 @@ module.exports = (async () => { })(); ``` +::: warning +ESLint only automatically looks for a config file named `eslint.config.js` and does not look for `eslint.config.cjs` or `eslint.config.mjs`. If you'd like to specify a different config filename than the default, use the `--config` command line option. +::: + ## Configuration Objects Each configuration object contains all of the information ESLint needs to execute on a set of files. Each configuration object is made up of these properties: @@ -667,7 +671,7 @@ When ESLint is run on the command line, it first checks the current working dire You can prevent this search for `eslint.config.js` by setting the `ESLINT_USE_FLAT_CONFIG` environment variable to `true` and using the `-c` or `--config` option on the command line to specify an alternate configuration file, such as: ```shell -ESLINT_USE_FLAT_CONFIG=true npx eslint -c some-other-file.js **/*.js +ESLINT_USE_FLAT_CONFIG=true npx eslint --config some-other-file.js **/*.js ``` In this case, ESLint does not search for `eslint.config.js` and instead uses `some-other-file.js`. From b066640b7040ec30f740dcc803511244fe19473b Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Aug 2023 20:35:13 +0530 Subject: [PATCH 11/17] chore: standardize npm script names (#17431) * chore: standardize npm script names * chore: use `build:minify-images` instead of `minify:images` --- docs/package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/package.json b/docs/package.json index ba2fe2472a45..85cbda38e1d2 100644 --- a/docs/package.json +++ b/docs/package.json @@ -9,18 +9,18 @@ "license": "MIT", "files": [], "scripts": { - "images": "imagemin '_site/assets/images' --out-dir='_site/assets/images'", - "watch:postcss": "postcss src/assets/css -d src/assets/css --watch --poll", - "watch:sass": "sass --watch --poll src/assets/scss:src/assets/css --no-source-map", - "watch:eleventy": "eleventy --serve --port=2023", + "build": "npm-run-all build:sass build:postcss build:website build:minify-images", "build:postcss": "postcss src/assets/css -d src/assets/css", + "build:postcss:watch": "postcss src/assets/css -d src/assets/css --watch --poll", "build:sass": "sass src/assets/scss:src/assets/css --no-source-map", - "build:eleventy": "npx @11ty/eleventy", - "start": "npm-run-all build:sass build:postcss --parallel watch:*", - "build": "npm-run-all build:sass build:postcss build:eleventy images", - "lint:scss": "stylelint \"**/*.{scss,html}\"", + "build:sass:watch": "sass --watch --poll src/assets/scss:src/assets/css --no-source-map", + "build:website": "npx @11ty/eleventy", + "build:website:watch": "eleventy --serve --port=2023", "lint:links": "cross-env NODE_OPTIONS=--max-old-space-size=4096 node tools/validate-links.js", - "lint:fix:scss": "npm run lint:scss -- --fix" + "lint:scss": "stylelint \"**/*.{scss,html}\"", + "lint:fix:scss": "npm run lint:scss -- --fix", + "build:minify-images": "imagemin '_site/assets/images' --out-dir='_site/assets/images'", + "start": "npm-run-all build:sass build:postcss --parallel *:*:watch" }, "devDependencies": { "@11ty/eleventy": "^1.0.1", From 757bfe1c35b5ddab7042d388f8d21e834875fff5 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 8 Aug 2023 13:11:34 -0400 Subject: [PATCH 12/17] chore: Remove add-to-triage (#17450) --- .github/workflows/add-to-triage.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/add-to-triage.yml diff --git a/.github/workflows/add-to-triage.yml b/.github/workflows/add-to-triage.yml deleted file mode 100644 index 83297dcab333..000000000000 --- a/.github/workflows/add-to-triage.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Add to Triage - -on: - issues: - types: - - opened - -jobs: - add-to-project: - name: Add issue to project - runs-on: ubuntu-latest - steps: - - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/eslint/projects/3 - github-token: ${{ secrets.PROJECT_BOT_TOKEN }} - labeled: "triage:no" - label-operator: NOT From 631648ee0b51a8951ce576ccd4430e09c9c8bcae Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Wed, 9 Aug 2023 17:13:04 +0200 Subject: [PATCH 13/17] fix: do not report on shadowed constructors in `no-new-wrappers` (#17447) * fix: do not report on shadowed constructors in `no-new-wrappers` * unit tests for undefined constructors --- lib/rules/no-new-wrappers.js | 26 +++++++++++----- tests/lib/rules/no-new-wrappers.js | 49 +++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/lib/rules/no-new-wrappers.js b/lib/rules/no-new-wrappers.js index 9a12e1a3b5d2..5050a98a044a 100644 --- a/lib/rules/no-new-wrappers.js +++ b/lib/rules/no-new-wrappers.js @@ -5,6 +5,12 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const { getVariableByName } = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -28,18 +34,24 @@ module.exports = { }, create(context) { + const { sourceCode } = context; return { NewExpression(node) { const wrapperObjects = ["String", "Number", "Boolean"]; - - if (wrapperObjects.includes(node.callee.name)) { - context.report({ - node, - messageId: "noConstructor", - data: { fn: node.callee.name } - }); + const { name } = node.callee; + + if (wrapperObjects.includes(name)) { + const variable = getVariableByName(sourceCode.getScope(node), name); + + if (variable && variable.identifiers.length === 0) { + context.report({ + node, + messageId: "noConstructor", + data: { fn: name } + }); + } } } }; diff --git a/tests/lib/rules/no-new-wrappers.js b/tests/lib/rules/no-new-wrappers.js index 57dba4e12851..0b5b686aef15 100644 --- a/tests/lib/rules/no-new-wrappers.js +++ b/tests/lib/rules/no-new-wrappers.js @@ -21,7 +21,36 @@ const ruleTester = new RuleTester(); ruleTester.run("no-new-wrappers", rule, { valid: [ "var a = new Object();", - "var a = String('test'), b = String.fromCharCode(32);" + "var a = String('test'), b = String.fromCharCode(32);", + ` + function test(Number) { + return new Number; + } + `, + { + code: ` + import String from "./string"; + const str = new String(42); + `, + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + ` + if (foo) { + result = new Boolean(bar); + } else { + var Boolean = CustomBoolean; + } + `, + { + code: "new String()", + globals: { + String: "off" + } + }, + ` + /* global Boolean:off */ + assert(new Boolean); + ` ], invalid: [ { @@ -53,6 +82,24 @@ ruleTester.run("no-new-wrappers", rule, { }, type: "NewExpression" }] + }, + { + code: ` + const a = new String('bar'); + { + const String = CustomString; + const b = new String('foo'); + } + `, + parserOptions: { ecmaVersion: 6 }, + errors: [{ + messageId: "noConstructor", + data: { + fn: "String" + }, + type: "NewExpression", + line: 2 + }] } ] }); From 0e4576012ab938b880e6f27641bff55fb4313d20 Mon Sep 17 00:00:00 2001 From: ESLint Jenkins Date: Fri, 11 Aug 2023 10:56:19 -0400 Subject: [PATCH 14/17] chore: package.json update for @eslint/js release --- packages/js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/package.json b/packages/js/package.json index e5f79c7cc457..1847404d7c99 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,6 +1,6 @@ { "name": "@eslint/js", - "version": "8.46.0", + "version": "8.47.0", "description": "ESLint JavaScript language implementation", "main": "./src/index.js", "scripts": {}, From bf69aa6408f5403a88d8c9b71b0e58232b1ea833 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 11 Aug 2023 11:14:20 -0400 Subject: [PATCH 15/17] chore: Update dependencies (#17456) --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ece696efe4eb..ccab1e9e803a 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,8 @@ "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.1", - "@eslint/js": "^8.46.0", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "^8.47.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -74,7 +74,7 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.2", + "eslint-visitor-keys": "^3.4.3", "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", From 928cecc754da77e1e52304b0a71b8b0a3a23fd7a Mon Sep 17 00:00:00 2001 From: ESLint Jenkins Date: Fri, 11 Aug 2023 11:18:14 -0400 Subject: [PATCH 16/17] Build: changelog update for 8.47.0 --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 001632b74bc5..b749600969e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +v8.47.0 - August 11, 2023 + +* [`bf69aa6`](https://github.com/eslint/eslint/commit/bf69aa6408f5403a88d8c9b71b0e58232b1ea833) chore: Update dependencies (#17456) (Nicholas C. Zakas) +* [`0e45760`](https://github.com/eslint/eslint/commit/0e4576012ab938b880e6f27641bff55fb4313d20) chore: package.json update for @eslint/js release (ESLint Jenkins) +* [`631648e`](https://github.com/eslint/eslint/commit/631648ee0b51a8951ce576ccd4430e09c9c8bcae) fix: do not report on shadowed constructors in `no-new-wrappers` (#17447) (Francesco Trotta) +* [`757bfe1`](https://github.com/eslint/eslint/commit/757bfe1c35b5ddab7042d388f8d21e834875fff5) chore: Remove add-to-triage (#17450) (Nicholas C. Zakas) +* [`b066640`](https://github.com/eslint/eslint/commit/b066640b7040ec30f740dcc803511244fe19473b) chore: standardize npm script names (#17431) (Nitin Kumar) +* [`a766a48`](https://github.com/eslint/eslint/commit/a766a48030d4359db76523d5b413d6332130e485) docs: document lack of config file names (#17442) (James) +* [`a1635d6`](https://github.com/eslint/eslint/commit/a1635d6198a8baf6571b3351e098e5ac960be887) docs: Update README (GitHub Actions Bot) +* [`6b2410f`](https://github.com/eslint/eslint/commit/6b2410f911dd2e3d915c879041c6e257d41a2f4e) chore: Update add-to-triage.yml (#17444) (Nicholas C. Zakas) +* [`47a0859`](https://github.com/eslint/eslint/commit/47a08597966651975126dd6726939cd34f13b80e) docs: update `require-unicode-regexp.md` as following up #17402 (#17441) (SUZUKI Sosuke) +* [`53d7508`](https://github.com/eslint/eslint/commit/53d750800b1c0c1f8c29393c488bb3167bb1d2a5) feat: update regex for methods with `thisArg` (#17439) (Francesco Trotta) +* [`fcdc85d`](https://github.com/eslint/eslint/commit/fcdc85d3a6bc14970c3349cc8d6f3a47eca172a3) docs: Update README (GitHub Actions Bot) +* [`2a92b6c`](https://github.com/eslint/eslint/commit/2a92b6cc9520a27255520369206556e9841a3af8) docs: update with "Specifying Parser Options" (#17435) (Cheol-Won) +* [`d743ed3`](https://github.com/eslint/eslint/commit/d743ed3c06c62a639da0389ad27907b324ea1715) docs: add metadata for parser/processor (#17438) (Huáng Jùnliàng) +* [`224376c`](https://github.com/eslint/eslint/commit/224376cd99a08394291a9584ad9c1ea1283673c6) docs: Update README (GitHub Actions Bot) +* [`a41a8e4`](https://github.com/eslint/eslint/commit/a41a8e4a7da14726d6fce71a023f12101fd52fdb) docs: update script names in README (#17432) (Nitin Kumar) + v8.46.0 - July 28, 2023 * [`d1eb7e4`](https://github.com/eslint/eslint/commit/d1eb7e46e954c64af8d7d13d087b3a18f43e6d72) chore: Update ecosystem dependencies (#17427) (Nicholas C. Zakas) From 98b155fb9d8ae5afa8c544453133d0c5a12c12ba Mon Sep 17 00:00:00 2001 From: ESLint Jenkins Date: Fri, 11 Aug 2023 11:18:14 -0400 Subject: [PATCH 17/17] 8.47.0 --- docs/package.json | 2 +- docs/src/use/formatters/html-formatter-example.html | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/package.json b/docs/package.json index 85cbda38e1d2..981b67d4e29c 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,7 +1,7 @@ { "name": "docs-eslint", "private": true, - "version": "8.46.0", + "version": "8.47.0", "description": "", "main": "index.js", "keywords": [], diff --git a/docs/src/use/formatters/html-formatter-example.html b/docs/src/use/formatters/html-formatter-example.html index d7e362c12fcb..4f87732fd189 100644 --- a/docs/src/use/formatters/html-formatter-example.html +++ b/docs/src/use/formatters/html-formatter-example.html @@ -118,7 +118,7 @@

ESLint Report

- 9 problems (5 errors, 4 warnings) - Generated on Fri Jul 28 2023 12:04:41 GMT-0400 (Eastern Daylight Time) + 9 problems (5 errors, 4 warnings) - Generated on Fri Aug 11 2023 11:18:15 GMT-0400 (Eastern Daylight Time)
diff --git a/package.json b/package.json index ccab1e9e803a..661e8fcaf4d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "8.46.0", + "version": "8.47.0", "author": "Nicholas C. Zakas ", "description": "An AST-based pattern checker for JavaScript.", "bin": {