@antfu/eslint-config 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -11
- package/dist/cli.cjs +6 -4
- package/dist/cli.js +6 -4
- package/dist/index.cjs +311 -206
- package/dist/index.d.cts +157 -14
- package/dist/index.d.ts +157 -14
- package/dist/index.js +307 -206
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package
|
|
|
33
33
|
// eslint.config.js
|
|
34
34
|
import antfu from '@antfu/eslint-config'
|
|
35
35
|
|
|
36
|
-
export default
|
|
36
|
+
export default antfu()
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
With CJS:
|
|
@@ -120,6 +120,7 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
120
120
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
121
121
|
"eslint.rules.customizations": [
|
|
122
122
|
{ "rule": "style/*", "severity": "off" },
|
|
123
|
+
{ "rule": "prettier/*", "severity": "off" },
|
|
123
124
|
{ "rule": "*-indent", "severity": "off" },
|
|
124
125
|
{ "rule": "*-spacing", "severity": "off" },
|
|
125
126
|
{ "rule": "*-spaces", "severity": "off" },
|
|
@@ -156,7 +157,7 @@ Normally you only need to import the `antfu` preset:
|
|
|
156
157
|
// eslint.config.js
|
|
157
158
|
import antfu from '@antfu/eslint-config'
|
|
158
159
|
|
|
159
|
-
export default
|
|
160
|
+
export default antfu()
|
|
160
161
|
```
|
|
161
162
|
|
|
162
163
|
And that's it! Or you can configure each integration individually, for example:
|
|
@@ -165,7 +166,7 @@ And that's it! Or you can configure each integration individually, for example:
|
|
|
165
166
|
// eslint.config.js
|
|
166
167
|
import antfu from '@antfu/eslint-config'
|
|
167
168
|
|
|
168
|
-
export default
|
|
169
|
+
export default antfu({
|
|
169
170
|
// Enable stylistic formatting rules
|
|
170
171
|
// stylistic: true,
|
|
171
172
|
|
|
@@ -197,7 +198,7 @@ The `antfu` factory function also accepts any number of arbitrary custom config
|
|
|
197
198
|
// eslint.config.js
|
|
198
199
|
import antfu from '@antfu/eslint-config'
|
|
199
200
|
|
|
200
|
-
export default
|
|
201
|
+
export default antfu(
|
|
201
202
|
{
|
|
202
203
|
// Configures for antfu's config
|
|
203
204
|
},
|
|
@@ -242,7 +243,7 @@ import {
|
|
|
242
243
|
yaml,
|
|
243
244
|
} from '@antfu/eslint-config'
|
|
244
245
|
|
|
245
|
-
export default
|
|
246
|
+
export default combine(
|
|
246
247
|
ignores(),
|
|
247
248
|
javascript(/* Options */),
|
|
248
249
|
comments(),
|
|
@@ -295,7 +296,7 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
|
|
|
295
296
|
// eslint.config.js
|
|
296
297
|
import antfu from '@antfu/eslint-config'
|
|
297
298
|
|
|
298
|
-
export default
|
|
299
|
+
export default antfu(
|
|
299
300
|
{ vue: true, typescript: true },
|
|
300
301
|
{
|
|
301
302
|
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
|
|
@@ -313,7 +314,7 @@ export default await antfu(
|
|
|
313
314
|
)
|
|
314
315
|
```
|
|
315
316
|
|
|
316
|
-
We also provided
|
|
317
|
+
We also provided an `overrides` options to make it easier:
|
|
317
318
|
|
|
318
319
|
```js
|
|
319
320
|
// eslint.config.js
|
|
@@ -339,7 +340,7 @@ We provide some optional configs for specific use cases, that we don't include t
|
|
|
339
340
|
|
|
340
341
|
#### React
|
|
341
342
|
|
|
342
|
-
To enable React support
|
|
343
|
+
To enable React support you need to explicitly turn it on:
|
|
343
344
|
|
|
344
345
|
```js
|
|
345
346
|
// eslint.config.js
|
|
@@ -358,7 +359,7 @@ npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refre
|
|
|
358
359
|
|
|
359
360
|
#### UnoCSS
|
|
360
361
|
|
|
361
|
-
To enable UnoCSS support, need to explicitly turn it on:
|
|
362
|
+
To enable UnoCSS support, you need to explicitly turn it on:
|
|
362
363
|
|
|
363
364
|
```js
|
|
364
365
|
// eslint.config.js
|
|
@@ -476,9 +477,15 @@ If you enjoy this code style, and would like to mention it in your project, here
|
|
|
476
477
|
|
|
477
478
|
[Why I don't use Prettier](https://antfu.me/posts/why-not-prettier)
|
|
478
479
|
|
|
479
|
-
|
|
480
|
+
Well, on the other hand, you can [use still Prettier to handle CSS and HTML formatting](#prettier), which is not yet supported by ESLint.
|
|
481
|
+
|
|
482
|
+
### How to format CSS?
|
|
483
|
+
|
|
484
|
+
~~This config does NOT lint CSS. I personally use [UnoCSS](https://github.com/unocss/unocss) so I don't write CSS.~~
|
|
485
|
+
|
|
486
|
+
Yes, we do now! See [Prettier](#prettier) section for more details.
|
|
480
487
|
|
|
481
|
-
|
|
488
|
+
For better linting, we recommend trying [stylelint](https://stylelint.io/).
|
|
482
489
|
|
|
483
490
|
### I prefer XXX...
|
|
484
491
|
|
package/dist/cli.cjs
CHANGED
|
@@ -46,9 +46,10 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.1
|
|
49
|
+
var version = "2.2.1";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/eslint-config": "workspace:*",
|
|
52
|
+
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
52
53
|
"@antfu/ni": "^0.21.12",
|
|
53
54
|
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
54
55
|
"@types/eslint": "^8.44.8",
|
|
@@ -98,6 +99,7 @@ var vscodeSettingsString = `
|
|
|
98
99
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
99
100
|
"eslint.rules.customizations": [
|
|
100
101
|
{ "rule": "style/*", "severity": "off" },
|
|
102
|
+
{ "rule": "prettier/*", "severity": "off" },
|
|
101
103
|
{ "rule": "*-indent", "severity": "off" },
|
|
102
104
|
{ "rule": "*-spacing", "severity": "off" },
|
|
103
105
|
{ "rule": "*-spaces", "severity": "off" },
|
|
@@ -141,7 +143,7 @@ async function run(options = {}) {
|
|
|
141
143
|
const cwd = import_node_process.default.cwd();
|
|
142
144
|
const pathFlatConfig = import_node_path.default.join(cwd, "eslint.config.js");
|
|
143
145
|
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
144
|
-
const
|
|
146
|
+
const pathESLintIgnore = import_node_path.default.join(cwd, ".eslintignore");
|
|
145
147
|
if (import_node_fs.default.existsSync(pathFlatConfig)) {
|
|
146
148
|
console.log(import_picocolors2.default.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
|
|
147
149
|
return;
|
|
@@ -158,9 +160,9 @@ async function run(options = {}) {
|
|
|
158
160
|
await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
159
161
|
console.log(import_picocolors2.default.green(`${CHECK} changes wrote to package.json`));
|
|
160
162
|
const eslintIgnores = [];
|
|
161
|
-
if (import_node_fs.default.existsSync(
|
|
163
|
+
if (import_node_fs.default.existsSync(pathESLintIgnore)) {
|
|
162
164
|
console.log(import_picocolors2.default.cyan(`${ARROW} migrating existing .eslintignore`));
|
|
163
|
-
const content = await import_promises.default.readFile(
|
|
165
|
+
const content = await import_promises.default.readFile(pathESLintIgnore, "utf-8");
|
|
164
166
|
const parsed = (0, import_parse_gitignore.default)(content);
|
|
165
167
|
const globs = parsed.globs();
|
|
166
168
|
for (const glob of globs) {
|
package/dist/cli.js
CHANGED
|
@@ -17,9 +17,10 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.1
|
|
20
|
+
var version = "2.2.1";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/eslint-config": "workspace:*",
|
|
23
|
+
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
23
24
|
"@antfu/ni": "^0.21.12",
|
|
24
25
|
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
25
26
|
"@types/eslint": "^8.44.8",
|
|
@@ -69,6 +70,7 @@ var vscodeSettingsString = `
|
|
|
69
70
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
70
71
|
"eslint.rules.customizations": [
|
|
71
72
|
{ "rule": "style/*", "severity": "off" },
|
|
73
|
+
{ "rule": "prettier/*", "severity": "off" },
|
|
72
74
|
{ "rule": "*-indent", "severity": "off" },
|
|
73
75
|
{ "rule": "*-spacing", "severity": "off" },
|
|
74
76
|
{ "rule": "*-spaces", "severity": "off" },
|
|
@@ -112,7 +114,7 @@ async function run(options = {}) {
|
|
|
112
114
|
const cwd = process.cwd();
|
|
113
115
|
const pathFlatConfig = path.join(cwd, "eslint.config.js");
|
|
114
116
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
115
|
-
const
|
|
117
|
+
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
116
118
|
if (fs.existsSync(pathFlatConfig)) {
|
|
117
119
|
console.log(c2.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
|
|
118
120
|
return;
|
|
@@ -129,9 +131,9 @@ async function run(options = {}) {
|
|
|
129
131
|
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
130
132
|
console.log(c2.green(`${CHECK} changes wrote to package.json`));
|
|
131
133
|
const eslintIgnores = [];
|
|
132
|
-
if (fs.existsSync(
|
|
134
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
|
133
135
|
console.log(c2.cyan(`${ARROW} migrating existing .eslintignore`));
|
|
134
|
-
const content = await fsp.readFile(
|
|
136
|
+
const content = await fsp.readFile(pathESLintIgnore, "utf-8");
|
|
135
137
|
const parsed = parse(content);
|
|
136
138
|
const globs = parsed.globs();
|
|
137
139
|
for (const glob of globs) {
|