Skip to content

Commit

Permalink
chore: switch eslint-config-eslint to the flat format (#17247)
Browse files Browse the repository at this point in the history
* chore: switch eslint-config-eslint to the flat format

1. convert eslint-config-eslint to the flat format.
2. export eslint-config-eslint/eslintrc (used by testing).
3. upgrade `eslint-plugin-n` v16 (added flat config supports).
4. change eslint plugins peerDependencies => dependencies.
5. change lib/eslint/eslint.js, lib/eslint/flat-eslint.js test cases
to make the ci happy.

note: it's a breaking change for eslint-config-eslint.

refs: https://eslint.org/docs/latest/use/configure/configuration-files-new

* fix: add linterOptions

* chore: update comments as .eslintrc.js is no longer needed for testing
  • Loading branch information
aladdin-add committed Jun 20, 2023
1 parent 391ed38 commit b991640
Show file tree
Hide file tree
Showing 11 changed files with 897 additions and 388 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.js
Expand Up @@ -6,8 +6,7 @@
* Internally, ESLint is using the eslint.config.js file to lint itself.
* This file is needed too, because:
*
* 1. There are tests that expect .eslintrc.js to be present to actually run.
* 2. ESLint VS Code extension expects eslintrc config files to be
* 1. ESLint VS Code extension expects eslintrc config files to be
* present to work correctly.
*
* Once we no longer need to support both eslintrc and flat config, we will
Expand Down Expand Up @@ -63,7 +62,7 @@ module.exports = {
"internal-rules"
],
extends: [
"eslint"
"eslint/eslintrc"
],
parserOptions: {
ecmaVersion: 2021
Expand Down
10 changes: 2 additions & 8 deletions eslint.config.js
Expand Up @@ -29,20 +29,14 @@ const path = require("path");
const internalPlugin = require("eslint-plugin-internal-rules");
const eslintPluginRulesRecommendedConfig = require("eslint-plugin-eslint-plugin/configs/rules-recommended");
const eslintPluginTestsRecommendedConfig = require("eslint-plugin-eslint-plugin/configs/tests-recommended");
const { FlatCompat } = require("@eslint/eslintrc");
const js = require("./packages/js");
const globals = require("globals");
const merge = require("lodash.merge");
const baseConfig = require("eslint-config-eslint");

//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
});

const INTERNAL_FILES = {
CLI_ENGINE_PATTERN: "lib/cli-engine/**/*",
LINTER_PATTERN: "lib/linter/**/*",
Expand Down Expand Up @@ -81,7 +75,7 @@ function createInternalFilesPatterns(pattern = null) {
}

module.exports = [
...compat.extends("eslint"),
...baseConfig,
{
ignores: [
"build/**",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -116,7 +116,7 @@
"eslint-plugin-eslint-plugin": "^5.1.0",
"eslint-plugin-internal-rules": "file:tools/internal-rules",
"eslint-plugin-jsdoc": "^38.1.6",
"eslint-plugin-n": "^15.2.4",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-unicorn": "^42.0.0",
"eslint-release": "^3.2.0",
"eslump": "^3.0.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/eslint-config-eslint/README.md
Expand Up @@ -22,12 +22,11 @@ npm install eslint-config-eslint --save-dev

## Usage

In your `.eslintrc` file, add:
In your `eslint.config.js` file, add:

```json
{
"extends": "eslint"
}
```js
const eslintConfig = require("eslint-config-eslint");
module.exports = eslintConfig;
```

### Where to ask for help?
Expand Down

0 comments on commit b991640

Please sign in to comment.