Skip to content

Commit 9baee55

Browse files
authored
feat!: rename configs (#587)
* feat!: rename configs * Create seven-boxes-call.md * fix test * format * Update docs/started.md
1 parent 8cb3d00 commit 9baee55

File tree

6 files changed

+56
-60
lines changed

6 files changed

+56
-60
lines changed

Diff for: .changeset/seven-boxes-call.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@intlify/eslint-plugin-vue-i18n": major
3+
---
4+
5+
feat!: rename configs

Diff for: docs/started.md

+29-43
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default [
3131
// js.configs.recommended, // '@eslint/js'
3232
// ...vue.configs['flat/recommended'], // 'eslint-plugin-vue'
3333

34-
...vueI18n.configs['flat/recommended'],
34+
...vueI18n.configs.recommended,
3535
{
3636
rules: {
3737
// Optional.
@@ -86,8 +86,8 @@ See the [rule list](./rules/index.md) to get the `configs` & `rules` that this p
8686

8787
This plugin provides some predefined configs. You can use the following configs by adding them to `eslint.config.[c|m]js`. (All flat configs in this plugin are provided as arrays, so spread syntax is required when combining them with other configs.)
8888

89-
- `*.configs["flat/base"]`: Settings and rules to enable correct ESLint parsing.
90-
- `*.configs["flat/recommended"]`: Above, plus rules to enforce subjective community defaults to ensure consistency.
89+
- `*.configs.base`: Settings and rules to enable correct ESLint parsing.
90+
- `*.configs.recommended`: Above, plus rules to enforce subjective community defaults to ensure consistency.
9191

9292
### Configuration `.eslintrc.*`
9393

@@ -102,7 +102,7 @@ module.export = {
102102
extends: [
103103
'eslint:recommended',
104104
// Recommended
105-
'plugin:@intlify/vue-i18n/recommended'
105+
'plugin:@intlify/vue-i18n/recommended-legacy'
106106
],
107107
rules: {
108108
// Optional.
@@ -156,8 +156,8 @@ See the [rule list](./rules/index.md) to get the `configs` & `rules` that this p
156156

157157
This plugin provides some predefined configs. You can use the following configs by adding them to `.eslintrc.*`.
158158

159-
- `"plugin:@intlify/vue-i18n/base"`: Settings and rules to enable correct ESLint parsing.
160-
- `"plugin:@intlify/vue-i18n/recommended"`: Above, plus rules to enforce subjective community defaults to ensure consistency.
159+
- `"plugin:@intlify/vue-i18n/base-legacy"`: Settings and rules to enable correct ESLint parsing.
160+
- `"plugin:@intlify/vue-i18n/recommended-legacy"`: Above, plus rules to enforce subjective community defaults to ensure consistency.
161161

162162
### `settings['vue-i18n']`
163163

@@ -201,24 +201,21 @@ eslint "src/**/*.{js,vue,json}"
201201

202202
If you want to use custom parsers such as [babel-eslint](https://www.npmjs.com/package/babel-eslint) or [typescript-eslint-parser](https://www.npmjs.com/package/typescript-eslint-parser), you have to use `parserOptions.parser` option instead of `parser` option. Because this plugin requires [vue-eslint-parser](https://www.npmjs.com/package/vue-eslint-parser) to parse `.vue` files, so this plugin doesn't work if you overwrote `parser` option.
203203

204-
Also, `parserOptions` configured at the top level affect `.json` and `.yaml`. This plugin needs to use special parsers to parse `.json` and `.yaml`, so to correctly parse each extension, use the `overrides` option and overwrite the options again.
205-
206204
```diff
207-
- "parser": "babel-eslint",
208-
"parserOptions": {
209-
+ "parser": "babel-eslint",
205+
import vueEslintParser from "vue-eslint-parser"
206+
import babelEslint from "babel-eslint"
207+
208+
export default {
209+
"files": ["**/*.vue"],
210+
"languageOptions": {
211+
- "parser": babelEslint,
212+
+ "parser": vueEslintParser,
213+
"parserOptions": {
214+
+ "parser": babelEslint,
210215
"sourceType": "module"
211-
},
212-
+ "overrides": [
213-
+ {
214-
+ "files": ["*.json", "*.json5"],
215-
+ "extends": ["plugin:@intlify/vue-i18n/base"],
216-
+ },
217-
+ {
218-
+ "files": ["*.yaml", "*.yml"],
219-
+ "extends": ["plugin:@intlify/vue-i18n/base"],
220-
+ }
221-
+ ]
216+
},
217+
}
218+
}
222219
```
223220

224221
### More lint on JSON and YAML in `<i18n>` block
@@ -233,34 +230,23 @@ You can also use [jsonc/vue-custom-block/no-parsing-error](https://ota-meshi.git
233230

234231
The most rules of `eslint-plugin-vue-i18n` require `vue-eslint-parser` to check `<template>` ASTs.
235232

236-
Make sure you have one of the following settings in your **.eslintrc**:
233+
Make sure you have one of the following settings in your **eslint.config.js**:
237234

238-
- `"extends": ["plugin:@intlify/vue-i18n/recommended"]`
239-
- `"extends": ["plugin:@intlify/vue-i18n/base"]`
235+
- `plugin.configs.base`
236+
- `plugin.configs.recommended`
240237

241-
If you already use other parser (e.g. `"parser": "babel-eslint"`), please move it into `parserOptions`, so it doesn't collide with the `vue-eslint-parser` used by this plugin's configuration:
242-
243-
```diff
244-
- "parser": "babel-eslint",
245-
"parserOptions": {
246-
+ "parser": "babel-eslint",
247-
"ecmaVersion": 2017,
248-
"sourceType": "module"
249-
}
250-
```
251-
252-
See also: "[Use together with custom parsers](#use-together-with-custom-parsers)" section.
238+
See also: "[How to use custom parser](#how-to-use-custom-parser)" section.
253239

254240
### Why doesn't it work on .vue file?
255241

256242
1. Make sure you don't have `eslint-plugin-html` in your config. The `eslint-plugin-html` extracts the content from `<script>` tags, but `eslint-plugin-vue` requires `<script>` tags and `<template>` tags in order to distinguish template and script in single file components.
257243

258-
```diff
259-
"plugins": [
260-
"vue",
261-
- "html"
262-
]
263-
```
244+
```diff
245+
"plugins": [
246+
"vue",
247+
- "html"
248+
]
249+
```
264250

265251
2. Make sure your tool is set to lint `.vue` and `.json` files.
266252

Diff for: lib/index.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** DON'T EDIT THIS FILE; was created by scripts. */
22
// configs
3-
import base from './configs/base'
4-
import recommended from './configs/recommended'
5-
import flatBase from './configs/flat/base'
6-
import flatRecommended from './configs/flat/recommended'
3+
import baseLegacy from './configs/base'
4+
import recommendedLegacy from './configs/recommended'
5+
import base from './configs/flat/base'
6+
import recommended from './configs/flat/recommended'
77

88
// rules
99
import keyFormatStyle from './rules/key-format-style'
@@ -32,12 +32,14 @@ import validMessageSyntax from './rules/valid-message-syntax'
3232
export = {
3333
configs: {
3434
// eslintrc configs
35-
base,
36-
recommended,
35+
'base-legacy': baseLegacy,
36+
'recommended-legacy': recommendedLegacy,
3737

3838
// flat configs
39-
'flat/base': flatBase,
40-
'flat/recommended': flatRecommended
39+
base,
40+
recommended,
41+
'flat/base': base,
42+
'flat/recommended': recommended
4143
},
4244
rules: {
4345
'key-format-style': keyFormatStyle,

Diff for: scripts/update-index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export async function update() {
99
const raw = `/** DON'T EDIT THIS FILE; was created by scripts. */
1010
// configs
1111
${PRESETS.map(
12-
preset => `import ${camelCase(preset)} from './configs/${preset}';`
12+
preset =>
13+
`import ${camelCase(`${preset}-legacy`)} from './configs/${preset}';`
1314
).join('\n')}
1415
${PRESETS.map(
15-
preset =>
16-
`import ${camelCase(`flat-${preset}`)} from './configs/flat/${preset}';`
16+
preset => `import ${camelCase(`${preset}`)} from './configs/flat/${preset}';`
1717
).join('\n')}
1818
1919
// rules
@@ -25,12 +25,12 @@ ${ruleNames
2525
export = {
2626
configs: {
2727
// eslintrc configs
28-
${PRESETS.map(preset => `'${preset}': ${camelCase(preset)},`).join('\n')}
28+
${PRESETS.map(preset => `'${preset}-legacy': ${camelCase(`${preset}-legacy`)},`).join('\n')}
2929
3030
// flat configs
31-
${PRESETS.map(
32-
preset => `'flat/${preset}': ${camelCase(`flat-${preset}`)},`
33-
).join('\n')}
31+
${PRESETS.map(preset => `'${preset}': ${camelCase(preset)},`).join('\n')}
32+
// flat configs (Backward compatibility)
33+
${PRESETS.map(preset => `'flat/${preset}': ${camelCase(preset)},`).join('\n')}
3434
},
3535
rules: {
3636
${ruleNames

Diff for: tests/integrations/flat-config/eslint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import vueI18n from '@intlify/eslint-plugin-vue-i18n'
33

44
export default [
55
...vue.configs['flat/recommended'],
6-
...vueI18n.configs['flat/recommended'],
6+
...vueI18n.configs.recommended,
77
{
88
rules: {
99
'vue/multi-word-component-names': 'off'

Diff for: tests/integrations/legacy-config/.eslintrc.cjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
module.exports = {
44
root: true,
5-
extends: ['plugin:vue/recommended', 'plugin:@intlify/vue-i18n/recommended'],
5+
extends: [
6+
'plugin:vue/recommended',
7+
'plugin:@intlify/vue-i18n/recommended-legacy'
8+
],
69
rules: {
710
'vue/multi-word-component-names': 'off'
811
},

0 commit comments

Comments
 (0)