Skip to content

Commit 4059169

Browse files
Copilotota-meshi
andauthored
Drop legacy ESLint config support - export flat config as main format (#527)
* Initial plan * Drop support for legacy config - make flat config the main export Co-authored-by: ota-meshi <16508807+ota-meshi@users.noreply.github.com> * Add changeset and update auto-generated config files Co-authored-by: ota-meshi <16508807+ota-meshi@users.noreply.github.com> * Update drop-legacy-config-support.md * Revert accidental change to docs/rules/index.md Co-authored-by: ota-meshi <16508807+ota-meshi@users.noreply.github.com> * update * Update rule documentation to use new config format Co-authored-by: ota-meshi <16508807+ota-meshi@users.noreply.github.com> * format * Fix docs/rules/index.md to use new config format Co-authored-by: ota-meshi <16508807+ota-meshi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ota-meshi <16508807+ota-meshi@users.noreply.github.com> Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
1 parent 692bb69 commit 4059169

42 files changed

Lines changed: 142 additions & 459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-yml": major
3+
---
4+
5+
Drop support for legacy ESLint config format. The plugin now exports flat configuration as the main configuration format. The previous `flat/*` namespace is kept for backward compatibility.

‎README.md‎

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ npm install --save-dev eslint eslint-plugin-yml
6565

6666
### Configuration
6767

68-
#### New Config (`eslint.config.js`)
69-
7068
Use `eslint.config.js` file to configure rules. See also: <https://eslint.org/docs/latest/use/configure/configuration-files-new>.
7169

7270
Example **eslint.config.js**:
@@ -76,7 +74,7 @@ import eslintPluginYml from 'eslint-plugin-yml';
7674
export default [
7775
// add more generic rule sets here, such as:
7876
// js.configs.recommended,
79-
...eslintPluginYml.configs['flat/recommended'],
77+
...eslintPluginYml.configs.recommended,
8078
{
8179
rules: {
8280
// override/add rules settings here, such as:
@@ -88,41 +86,14 @@ export default [
8886

8987
This plugin provides configs:
9088

91-
- `*.configs['flat/base']` ... Configuration to enable correct YAML parsing.
92-
- `*.configs['flat/recommended']` ... Above, plus rules to prevent errors or unintended behavior.
93-
- `*.configs['flat/standard']` ... Above, plus rules to enforce the common stylistic conventions.
94-
- `*.configs['flat/prettier']` ... Turn off rules that may conflict with [Prettier](https://prettier.io/).
89+
- `*.configs.base` ... Configuration to enable correct YAML parsing.
90+
- `*.configs.recommended` ... Above, plus rules to prevent errors or unintended behavior.
91+
- `*.configs.standard` ... Above, plus rules to enforce the common stylistic conventions.
92+
- `*.configs.prettier` ... Turn off rules that may conflict with [Prettier](https://prettier.io/).
9593

9694
See [the rule list](https://ota-meshi.github.io/eslint-plugin-yml/rules/) to get the `rules` that this plugin provides.
9795

98-
#### Legacy Config (`.eslintrc`)
99-
100-
Use `.eslintrc.*` file to configure rules. See also: <https://eslint.org/docs/latest/use/configure/>.
101-
102-
Example **.eslintrc.js**:
103-
104-
```js
105-
module.exports = {
106-
extends: [
107-
// add more generic rulesets here, such as:
108-
// 'eslint:recommended',
109-
"plugin:yml/standard",
110-
],
111-
rules: {
112-
// override/add rules settings here, such as:
113-
// 'yml/rule-name': 'error'
114-
},
115-
};
116-
```
117-
118-
This plugin provides configs:
119-
120-
- `plugin:yml/base` ... Configuration to enable correct YAML parsing.
121-
- `plugin:yml/recommended` ... Above, plus rules to prevent errors or unintended behavior.
122-
- `plugin:yml/standard` ... Above, plus rules to enforce the common stylistic conventions.
123-
- `plugin:yml/prettier` ... Turn off rules that may conflict with [Prettier](https://prettier.io/).
124-
125-
See [the rule list](https://ota-meshi.github.io/eslint-plugin-yml/rules/) to get the `rules` that this plugin provides.
96+
**Note:** The `*.configs['flat/*']` configs are still available for backward compatibility, but it is recommended to use the new config names without the `flat/` prefix.
12697

12798
#### Parser Configuration
12899

@@ -131,53 +102,51 @@ If you have specified a parser, you need to configure a parser for `.yaml`.
131102
For example, if you are using the `"@babel/eslint-parser"`, configure it as follows:
132103

133104
```js
134-
module.exports = {
135-
// ...
136-
extends: ["plugin:yml/standard"],
137-
// ...
138-
parser: "@babel/eslint-parser",
139-
// Add an `overrides` section to add a parser configuration for YAML.
140-
overrides: [
141-
{
142-
files: ["*.yaml", "*.yml"],
143-
parser: "yaml-eslint-parser",
105+
import eslintPluginYml from 'eslint-plugin-yml';
106+
import babelParser from '@babel/eslint-parser';
107+
108+
export default [
109+
...eslintPluginYml.configs.standard,
110+
{
111+
files: ['**/*.js'],
112+
languageOptions: {
113+
parser: babelParser,
144114
},
145-
],
146-
// ...
147-
};
115+
},
116+
// YAML files are already configured by the plugin
117+
];
148118
```
149119

150120
#### Parser Options
151121

152122
The following parser options for `yaml-eslint-parser` are available by specifying them in [parserOptions](https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options) in the ESLint configuration file.
153123

154124
```js
155-
module.exports = {
156-
// ...
157-
overrides: [
158-
{
159-
files: ["*.yaml", "*.yml"],
160-
parser: "yaml-eslint-parser",
161-
// Options used with yaml-eslint-parser.
125+
import eslintPluginYml from 'eslint-plugin-yml';
126+
127+
export default [
128+
...eslintPluginYml.configs.recommended,
129+
{
130+
files: ['**/*.yaml', '**/*.yml'],
131+
languageOptions: {
162132
parserOptions: {
163-
defaultYAMLVersion: "1.2",
133+
defaultYAMLVersion: '1.2',
164134
},
165135
},
166-
],
167-
// ...
168-
};
136+
},
137+
];
169138
```
170139

171140
See also [https://github.com/ota-meshi/yaml-eslint-parser#readme](https://github.com/ota-meshi/yaml-eslint-parser#readme).
172141

173142
### Running ESLint from the command line
174143

175-
If you want to run `eslint` from the command line, make sure you include the `.yaml` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern, because ESLint targets only `.js` files by default.
144+
With ESLint v9 and flat config, ESLint automatically lints all files matched by your config. You typically don't need the `--ext` option anymore.
176145

177146
Examples:
178147

179148
```bash
180-
eslint --ext .js,.yaml,.yml src
149+
eslint .
181150
eslint "src/**/*.{js,yaml,yml}"
182151
```
183152

‎docs/rules/block-mapping-colon-indicator-newline.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v1.2.0"
1010

1111
> enforce consistent line breaks after `:` indicator
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/block-mapping-question-indicator-newline.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.5.0"
1010

1111
> enforce consistent line breaks after `?` indicator
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/block-mapping.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.1.0"
1010

1111
> require or disallow block style mappings.
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/block-sequence-hyphen-indicator-newline.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.5.0"
1010

1111
> enforce consistent line breaks after `-` indicator
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/block-sequence.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.1.0"
1010

1111
> require or disallow block style sequences.
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/flow-mapping-curly-newline.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.1.0"
1010

1111
> enforce consistent line breaks inside braces
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/flow-mapping-curly-spacing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.1.0"
1010

1111
> enforce consistent spacing inside braces
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎docs/rules/flow-sequence-bracket-newline.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: "v0.1.0"
1010

1111
> enforce linebreaks after opening and before closing flow sequence brackets
1212
13-
- :gear: This rule is included in `"plugin:yml/standard"`.
13+
- :gear: This rule is included in `configs.standard`.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

0 commit comments

Comments
 (0)