Skip to content

Commit

Permalink
Merge branch 'main' into rfc-100-part2
Browse files Browse the repository at this point in the history
* main: (25 commits)
  test: ensure that CLI tests run with FlatESLint (eslint#17884)
  fix!: Behavior of CLI when no arguments are passed (eslint#17644)
  docs: Update README
  Revert "feat!: Remove CodePath#currentSegments" (eslint#17890)
  feat!: Update shouldUseFlatConfig and CLI so flat config is default (eslint#17748)
  feat!: Remove CodePath#currentSegments (eslint#17756)
  chore: update dependency markdownlint-cli to ^0.38.0 (eslint#17865)
  feat!: deprecate no-new-symbol, recommend no-new-native-nonconstructor (eslint#17710)
  feat!: check for parsing errors in suggestion fixes (eslint#16639)
  feat!: assert suggestion messages are unique in rule testers (eslint#17532)
  feat!: `no-invalid-regexp` make allowConstructorFlags case-sensitive (eslint#17533)
  fix!: no-sequences rule schema correction (eslint#17878)
  feat!: Update `eslint:recommended` configuration (eslint#17716)
  feat!: drop support for string configurations in flat config array (eslint#17717)
  feat!: Remove `SourceCode#getComments()` (eslint#17715)
  feat!: Remove deprecated context methods (eslint#17698)
  feat!: Swap FlatESLint-ESLint, FlatRuleTester-RuleTester in API (eslint#17823)
  feat!: remove formatters except html, json(-with-metadata), and stylish (eslint#17531)
  feat!: Require Node.js `^18.18.0 || ^20.9.0 || >=21.1.0` (eslint#17725)
  fix: allow circular references in config (eslint#17752)
  ...
  • Loading branch information
bmish committed Dec 21, 2023
2 parents bdfc123 + 595a1f6 commit ae4e075
Show file tree
Hide file tree
Showing 73 changed files with 7,245 additions and 12,339 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [21.x, 20.x, 19.x, 18.x, 17.x, 16.x, 14.x, 12.x, "12.22.0"]
node: [21.x, 20.x, 18.x, "18.18.0"]
include:
- os: windows-latest
node: "lts/*"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -43,7 +43,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
22 changes: 22 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,25 @@
v8.56.0 - December 15, 2023

* [`ba6af85`](https://github.com/eslint/eslint/commit/ba6af85c7d8ba55d37f8663aee949d148e441c1a) chore: upgrade @eslint/js@8.56.0 (#17864) (Milos Djermanovic)
* [`60a531a`](https://github.com/eslint/eslint/commit/60a531a9c0811ddf718e26b9136e133f580b6c36) chore: package.json update for @eslint/js release (Jenkins)
* [`0dd9704`](https://github.com/eslint/eslint/commit/0dd9704c4751e1cd02039f7d6485fee09bbccbf6) feat: Support custom severity when reporting unused disable directives (#17212) (Bryan Mishkin)
* [`31a7e3f`](https://github.com/eslint/eslint/commit/31a7e3fde491e36496b54e8905c766b31162d776) feat: fix no-restricted-properties false negatives with unknown objects (#17818) (Arka Pratim Chaudhuri)
* [`ba87a06`](https://github.com/eslint/eslint/commit/ba87a0651a65b52c3ac442b512dd9f4c2b4c5f57) chore: update dependency markdownlint to ^0.32.0 (#17783) (renovate[bot])
* [`7d5e5f6`](https://github.com/eslint/eslint/commit/7d5e5f68849ae80caec0fc96ecceebccd348deec) fix: `TypeError: fs.exists is not a function` on read-only file system (#17846) (Francesco Trotta)
* [`9271d10`](https://github.com/eslint/eslint/commit/9271d10d9eabeafb0129a090f29191bfd14273c0) chore: add GitHub issue template for docs issues (#17845) (Josh Goldberg ✨)
* [`70a686b`](https://github.com/eslint/eslint/commit/70a686b3c1feac5eca98bbff9bd67175f550d5db) chore: Convert rule tests to FlatRuleTester (#17819) (Nicholas C. Zakas)
* [`9007719`](https://github.com/eslint/eslint/commit/90077199fe519953f9af8664bf947db4e4958514) docs: update link in ways-to-extend.md (#17839) (Amel SELMANE)
* [`f3a599d`](https://github.com/eslint/eslint/commit/f3a599d34c7080fc0b2c9a60b5e54dc98c22867c) chore: upgrade eslint-plugin-unicorn to v49.0.0 (#17837) (唯然)
* [`905d4b7`](https://github.com/eslint/eslint/commit/905d4b75ab2df42aba30622cee0f66b511397e2c) chore: upgrade eslint-plugin-eslint-plugin v5.2.1 (#17838) (唯然)
* [`4d7c3ce`](https://github.com/eslint/eslint/commit/4d7c3ce246e6b499f472342ef59496a47cc033d6) chore: update eslint-plugin-n v16.4.0 (#17836) (唯然)
* [`3a22236`](https://github.com/eslint/eslint/commit/3a22236f8d10af8a5bcafe56092651d3d681c99d) docs: Update README (GitHub Actions Bot)
* [`54c3ca6`](https://github.com/eslint/eslint/commit/54c3ca6f2dcd2a7afd53f42fc32055a25587259e) docs: fix migration-guide example (#17829) (Tanuj Kanti)
* [`4391b71`](https://github.com/eslint/eslint/commit/4391b71e62b15e54b0493f0dce1ea053ebbc0689) docs: check config comments in rule examples (#17815) (Francesco Trotta)
* [`fd28363`](https://github.com/eslint/eslint/commit/fd2836342c2be4751b05fe0ba7cece17d1edecc8) docs: remove mention about ESLint stylistic rules in readme (#17810) (Zwyx)
* [`fd0c60c`](https://github.com/eslint/eslint/commit/fd0c60c3be1f213e5a6d69d8a3248e963619e155) ci: unpin Node.js 21.2.0 (#17821) (Francesco Trotta)
* [`48ed5a6`](https://github.com/eslint/eslint/commit/48ed5a6dad478a14d3e823f137455c523f373e0b) docs: Update README (GitHub Actions Bot)
* [`74739c8`](https://github.com/eslint/eslint/commit/74739c849bbb6547b0e555ed8bb2ba1cbe0fdce4) fix: suggestion with invalid syntax in no-promise-executor-return rule (#17812) (Bryan Mishkin)

v8.55.0 - December 1, 2023

* [`eb8950c`](https://github.com/eslint/eslint/commit/eb8950c3b811c9163b9aae23af8b6266ad98b295) chore: upgrade @eslint/js@8.55.0 (#17811) (Milos Djermanovic)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -43,7 +43,7 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J

## Installation and Usage

Prerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `>=16.0.0`) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.)
Prerequisites: [Node.js](https://nodejs.org/) (`^18.18.0`, `^20.9.0`, or `>=21.1.0`) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.)

You can install and configure ESLint using this command:

Expand Down Expand Up @@ -293,7 +293,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
<h3>Platinum Sponsors</h3>
<p><a href="#"><img src="https://images.opencollective.com/2021-frameworks-fund/logo.png" alt="Chrome Frameworks Fund" height="undefined"></a> <a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
<p><a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
<p><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>
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/eb04ddc/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>
<p><a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://transloadit.com/"><img src="https://avatars.githubusercontent.com/u/125754?v=4" alt="Transloadit" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
<!--sponsorsend-->

Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
@@ -1,7 +1,7 @@
{
"name": "docs-eslint",
"private": true,
"version": "8.55.0",
"version": "8.56.0",
"description": "",
"main": "index.js",
"keywords": [],
Expand Down
13 changes: 6 additions & 7 deletions docs/src/_data/rules.json
Expand Up @@ -228,13 +228,6 @@
{
"name": "no-new-native-nonconstructor",
"description": "Disallow `new` operators with global non-constructor functions",
"recommended": false,
"fixable": false,
"hasSuggestions": false
},
{
"name": "no-new-symbol",
"description": "Disallow `new` operators with the `Symbol` object",
"recommended": true,
"fixable": false,
"hasSuggestions": false
Expand Down Expand Up @@ -1737,6 +1730,12 @@
"fixable": false,
"hasSuggestions": false
},
{
"name": "no-new-symbol",
"replacedBy": [
"no-new-native-nonconstructor"
]
},
{
"name": "no-path-concat",
"replacedBy": [],
Expand Down
10 changes: 7 additions & 3 deletions docs/src/_data/rules_meta.json
Expand Up @@ -1433,7 +1433,7 @@
"type": "problem",
"docs": {
"description": "Disallow `new` operators with global non-constructor functions",
"recommended": false,
"recommended": true,
"url": "https://eslint.org/docs/latest/rules/no-new-native-nonconstructor"
}
},
Expand Down Expand Up @@ -1463,9 +1463,13 @@
"type": "problem",
"docs": {
"description": "Disallow `new` operators with the `Symbol` object",
"recommended": true,
"recommended": false,
"url": "https://eslint.org/docs/latest/rules/no-new-symbol"
}
},
"deprecated": true,
"replacedBy": [
"no-new-native-nonconstructor"
]
},
"no-new-wrappers": {
"type": "suggestion",
Expand Down
32 changes: 13 additions & 19 deletions docs/src/extend/custom-rules.md
Expand Up @@ -131,28 +131,14 @@ The `context` object has the following properties:
* `sourceCode`: (`object`) A `SourceCode` object that you can use to work with the source that was passed to ESLint (see [Accessing the Source Code](#accessing-the-source-code)).
* `settings`: (`object`) The [shared settings](../use/configure/configuration-files#adding-shared-settings) from the configuration.
* `parserPath`: (`string`) The name of the `parser` from the configuration.
* `parserServices`: (**Deprecated:** Use `SourceCode#parserServices` instead.) Contains parser-provided services for rules. The default parser does not provide any services. However, if a rule is intended to be used with a custom parser, it could use `parserServices` to access anything provided by that parser. (For example, a TypeScript parser could provide the ability to get the computed type of a given node.)
* `parserOptions`: The parser options configured for this run (more details [here](../use/configure/language-options#specifying-parser-options)).

Additionally, the `context` object has the following methods:

* `getAncestors()`: (**Deprecated:** Use `SourceCode#getAncestors(node)` instead.) Returns an array of the ancestors of the currently-traversed node, starting at the root of the AST and continuing through the direct parent of the current node. This array does not include the currently-traversed node itself.
* `getCwd()`: (**Deprecated:** Use `context.cwd` instead.) Returns the `cwd` option passed to the [Linter](../integrate/nodejs-api#linter). It is a path to a directory that should be considered the current working directory.
* `getDeclaredVariables(node)`: (**Deprecated:** Use `SourceCode#getDeclaredVariables(node)` instead.) Returns a list of [variables](./scope-manager-interface#variable-interface) declared by the given node. This information can be used to track references to variables.
* If the node is a `VariableDeclaration`, all variables declared in the declaration are returned.
* If the node is a `VariableDeclarator`, all variables declared in the declarator are returned.
* If the node is a `FunctionDeclaration` or `FunctionExpression`, the variable for the function name is returned, in addition to variables for the function parameters.
* If the node is an `ArrowFunctionExpression`, variables for the parameters are returned.
* If the node is a `ClassDeclaration` or a `ClassExpression`, the variable for the class name is returned.
* If the node is a `CatchClause`, the variable for the exception is returned.
* If the node is an `ImportDeclaration`, variables for all of its specifiers are returned.
* If the node is an `ImportSpecifier`, `ImportDefaultSpecifier`, or `ImportNamespaceSpecifier`, the declared variable is returned.
* Otherwise, if the node does not declare any variables, an empty array is returned.
* `getFilename()`: (**Deprecated:** Use `context.filename` instead.) Returns the filename associated with the source.
* `getPhysicalFilename()`: (**Deprecated:** Use `context.physicalFilename` instead.) When linting a file, it returns the full path of the file on disk without any code block information. When linting text, it returns the value passed to `—stdin-filename` or `<text>` if not specified.
* `getScope()`: (**Deprecated:** Use `SourceCode#getScope(node)` instead.) Returns the [scope](./scope-manager-interface#scope-interface) of the currently-traversed node. This information can be used to track references to variables.
* `getSourceCode()`: (**Deprecated:** Use `context.sourceCode` instead.) Returns a `SourceCode` object that you can use to work with the source that was passed to ESLint (see [Accessing the Source Code](#accessing-the-source-code)).
* `markVariableAsUsed(name)`: (**Deprecated:** Use `SourceCode#markVariableAsUsed(name, node)` instead.) Marks a variable with the given name in the current scope as used. This affects the [no-unused-vars](../rules/no-unused-vars) rule. Returns `true` if a variable with the given name was found and marked as used, otherwise `false`.
* `report(descriptor)`. Reports a problem in the code (see the [dedicated section](#reporting-problems)).

**Note:** Earlier versions of ESLint supported additional methods on the `context` object. Those methods were removed in the new format and should not be relied upon.
Expand Down Expand Up @@ -551,6 +537,19 @@ Once you have an instance of `SourceCode`, you can use the following methods on
* `getLocFromIndex(index)`: Returns an object with `line` and `column` properties, corresponding to the location of the given source index. `line` is 1-based and `column` is 0-based.
* `getIndexFromLoc(loc)`: Returns the index of a given location in the source code, where `loc` is an object with a 1-based `line` key and a 0-based `column` key.
* `commentsExistBetween(nodeOrToken1, nodeOrToken2)`: Returns `true` if comments exist between two nodes.
* `getAncestors(node)`: Returns an array of the ancestors of the given node, starting at the root of the AST and continuing through the direct parent of the given node. This array does not include the given node itself.
* `getDeclaredVariables(node)`: Returns a list of [variables](./scope-manager-interface#variable-interface) declared by the given node. This information can be used to track references to variables.
* If the node is a `VariableDeclaration`, all variables declared in the declaration are returned.
* If the node is a `VariableDeclarator`, all variables declared in the declarator are returned.
* If the node is a `FunctionDeclaration` or `FunctionExpression`, the variable for the function name is returned, in addition to variables for the function parameters.
* If the node is an `ArrowFunctionExpression`, variables for the parameters are returned.
* If the node is a `ClassDeclaration` or a `ClassExpression`, the variable for the class name is returned.
* If the node is a `CatchClause`, the variable for the exception is returned.
* If the node is an `ImportDeclaration`, variables for all of its specifiers are returned.
* If the node is an `ImportSpecifier`, `ImportDefaultSpecifier`, or `ImportNamespaceSpecifier`, the declared variable is returned.
* Otherwise, if the node does not declare any variables, an empty array is returned.
* `getScope(node)`: Returns the [scope](./scope-manager-interface#scope-interface) of the given node. This information can be used to track references to variables.
* `markVariableAsUsed(name, refNode)`: Marks a variable with the given name in a scope indicated by the given reference node as used. This affects the [no-unused-vars](../rules/no-unused-vars) rule. Returns `true` if a variable with the given name was found and marked as used, otherwise `false`.

`skipOptions` is an object which has 3 properties; `skip`, `includeComments`, and `filter`. Default is `{skip: 0, includeComments: false, filter: null}`.

Expand Down Expand Up @@ -787,8 +786,6 @@ To learn more about JSON Schema, we recommend looking at some examples on the [J

The `SourceCode#getScope(node)` method returns the scope of the given node. It is a useful method for finding information about the variables in a given scope and how they are used in other scopes.

**Deprecated:** The `context.getScope()` is deprecated; make sure to use `SourceCode#getScope(node)` instead.

#### Scope types

The following table contains a list of AST node types and the scope type that they correspond to. For more information about the scope types, refer to the [`Scope` object documentation](./scope-manager-interface#scope-interface).
Expand Down Expand Up @@ -836,8 +833,6 @@ For examples of using `SourceCode#getScope()` to track variables, refer to the s

### Marking Variables as Used

**Deprecated:** The `context.markVariableAsUsed()` method is deprecated in favor of `sourceCode.markVariableAsUsed()`.

Certain ESLint rules, such as [`no-unused-vars`](../rules/no-unused-vars), check to see if a variable has been used. ESLint itself only knows about the standard rules of variable access and so custom ways of accessing variables may not register as "used".

To help with this, you can use the `sourceCode.markVariableAsUsed()` method. This method takes two arguments: the name of the variable to mark as used and an option reference node indicating the scope in which you are working. Here's an example:
Expand Down Expand Up @@ -872,7 +867,6 @@ ESLint analyzes code paths while traversing AST. You can access code path object

Please note that the following `SourceCode` methods have been deprecated and will be removed in a future version of ESLint:

* `getComments()`: Replaced by `SourceCode#getCommentsBefore()`, `SourceCode#getCommentsAfter()`, and `SourceCode#getCommentsInside()`.
* `getTokenOrCommentBefore()`: Replaced by `SourceCode#getTokenBefore()` with the `{ includeComments: true }` option.
* `getTokenOrCommentAfter()`: Replaced by `SourceCode#getTokenAfter()` with the `{ includeComments: true }` option.
* `isSpaceBetweenTokens()`: Replaced by `SourceCode#isSpaceBetween()`
Expand Down
2 changes: 1 addition & 1 deletion docs/src/integrate/integration-tutorial.md
Expand Up @@ -33,7 +33,7 @@ This tutorial assumes you are familiar with JavaScript and Node.js.

To follow this tutorial, you'll need to have the following:

* Node.js (v12.22.0 or higher)
* Node.js (`^18.18.0`, `^20.9.0`, or `>=21.1.0`)
* npm
* A text editor

Expand Down
2 changes: 1 addition & 1 deletion docs/src/rules/no-invalid-regexp.md
Expand Up @@ -53,7 +53,7 @@ If you want to allow additional constructor flags for any reason, you can specif

This rule has an object option for exceptions:

* `"allowConstructorFlags"` is an array of flags
* `"allowConstructorFlags"` is a case-sensitive array of flags

### allowConstructorFlags

Expand Down
2 changes: 1 addition & 1 deletion docs/src/rules/no-new-symbol.md
Expand Up @@ -6,7 +6,7 @@ further_reading:
- https://www.ecma-international.org/ecma-262/6.0/#sec-symbol-objects
---


This rule was **deprecated** in ESLint v9.0.0 and replaced by the [no-new-native-nonconstructor](no-new-native-nonconstructor) rule.

`Symbol` is not intended to be used with the `new` operator, but to be called as a function.

Expand Down

0 comments on commit ae4e075

Please sign in to comment.