@aiou/eslint-config 2.0.1 → 2.0.2
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/dist/index.cjs +34 -3
- package/dist/index.mjs +34 -3
- package/dts/utils.d.ts +20 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -777,7 +777,8 @@ const markdown = () => {
|
|
|
777
777
|
// Code blocks in markdown file
|
|
778
778
|
files: [`${GLOB_MARKDOWN}/*.${GLOB_SCRIPT_EXT}`],
|
|
779
779
|
rules: {
|
|
780
|
-
|
|
780
|
+
// https://eslint-react.xyz/docs/migration
|
|
781
|
+
"react/no-missing-component-display-name": "off",
|
|
781
782
|
"@typescript-eslint/no-redeclare": "off",
|
|
782
783
|
"@typescript-eslint/no-unused-vars": "off",
|
|
783
784
|
"@typescript-eslint/no-use-before-define": "off",
|
|
@@ -3583,6 +3584,19 @@ function mapValues(object, iteratee) {
|
|
|
3583
3584
|
return result;
|
|
3584
3585
|
}
|
|
3585
3586
|
|
|
3587
|
+
function renameRules(rules, map) {
|
|
3588
|
+
return Object.fromEntries(
|
|
3589
|
+
Object.entries(rules).map(([key, value]) => {
|
|
3590
|
+
for (const [from, to] of Object.entries(map)) {
|
|
3591
|
+
if (key.startsWith(`${from}/`)) {
|
|
3592
|
+
return [to + key.slice(from.length), value];
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
return [key, value];
|
|
3596
|
+
})
|
|
3597
|
+
);
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3586
3600
|
const react = () => {
|
|
3587
3601
|
const plugins = pluginReact__default.default.configs.all.plugins;
|
|
3588
3602
|
const config = [
|
|
@@ -3612,14 +3626,31 @@ const react = () => {
|
|
|
3612
3626
|
"react-web-api": plugins["@eslint-react/web-api"]
|
|
3613
3627
|
},
|
|
3614
3628
|
rules: {
|
|
3615
|
-
...
|
|
3629
|
+
...renameRules(plugins["@eslint-react"].configs["recommended-typescript"].rules, { "@eslint-react": "react" }),
|
|
3630
|
+
...renameRules(plugins["@eslint-react/dom"].configs.recommended.rules, { "@eslint-react": "react-dom" }),
|
|
3631
|
+
...renameRules(pluginReactHooks__default.default.configs.recommended.rules, { "@eslint-react": "react-hooks" }),
|
|
3632
|
+
...renameRules(plugins["@eslint-react/hooks-extra"].configs.recommended.rules, { "@eslint-react": "react-hooks-extra" }),
|
|
3633
|
+
...renameRules(plugins["@eslint-react/naming-convention"].configs.recommended.rules, { "@eslint-react": "react-naming-convention" }),
|
|
3634
|
+
...renameRules(plugins["@eslint-react/web-api"].configs.recommended.rules, { "@eslint-react": "react-web-api" }),
|
|
3616
3635
|
"react/no-prop-types": "error",
|
|
3617
3636
|
"react-dom/no-unknown-property": "off",
|
|
3618
|
-
"react/avoid-shorthand-boolean": ["error"
|
|
3637
|
+
"react/avoid-shorthand-boolean": ["error"],
|
|
3619
3638
|
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
3620
3639
|
"react-refresh/only-export-components": "warn"
|
|
3621
3640
|
}
|
|
3622
3641
|
},
|
|
3642
|
+
{
|
|
3643
|
+
files: ["src/components/**/*.{ts,tsx}"],
|
|
3644
|
+
rules: {
|
|
3645
|
+
"react-naming-convention/filename": ["warn", { rule: "PascalCase" }]
|
|
3646
|
+
}
|
|
3647
|
+
},
|
|
3648
|
+
{
|
|
3649
|
+
files: ["src/hooks/**/use*.{ts,tsx}"],
|
|
3650
|
+
rules: {
|
|
3651
|
+
"react-naming-convention/filename": ["warn", { rule: "kebab-case" }]
|
|
3652
|
+
}
|
|
3653
|
+
},
|
|
3623
3654
|
{
|
|
3624
3655
|
files: [
|
|
3625
3656
|
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
package/dist/index.mjs
CHANGED
|
@@ -747,7 +747,8 @@ const markdown = () => {
|
|
|
747
747
|
// Code blocks in markdown file
|
|
748
748
|
files: [`${GLOB_MARKDOWN}/*.${GLOB_SCRIPT_EXT}`],
|
|
749
749
|
rules: {
|
|
750
|
-
|
|
750
|
+
// https://eslint-react.xyz/docs/migration
|
|
751
|
+
"react/no-missing-component-display-name": "off",
|
|
751
752
|
"@typescript-eslint/no-redeclare": "off",
|
|
752
753
|
"@typescript-eslint/no-unused-vars": "off",
|
|
753
754
|
"@typescript-eslint/no-use-before-define": "off",
|
|
@@ -3553,6 +3554,19 @@ function mapValues(object, iteratee) {
|
|
|
3553
3554
|
return result;
|
|
3554
3555
|
}
|
|
3555
3556
|
|
|
3557
|
+
function renameRules(rules, map) {
|
|
3558
|
+
return Object.fromEntries(
|
|
3559
|
+
Object.entries(rules).map(([key, value]) => {
|
|
3560
|
+
for (const [from, to] of Object.entries(map)) {
|
|
3561
|
+
if (key.startsWith(`${from}/`)) {
|
|
3562
|
+
return [to + key.slice(from.length), value];
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
return [key, value];
|
|
3566
|
+
})
|
|
3567
|
+
);
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3556
3570
|
const react = () => {
|
|
3557
3571
|
const plugins = pluginReact.configs.all.plugins;
|
|
3558
3572
|
const config = [
|
|
@@ -3582,14 +3596,31 @@ const react = () => {
|
|
|
3582
3596
|
"react-web-api": plugins["@eslint-react/web-api"]
|
|
3583
3597
|
},
|
|
3584
3598
|
rules: {
|
|
3585
|
-
...
|
|
3599
|
+
...renameRules(plugins["@eslint-react"].configs["recommended-typescript"].rules, { "@eslint-react": "react" }),
|
|
3600
|
+
...renameRules(plugins["@eslint-react/dom"].configs.recommended.rules, { "@eslint-react": "react-dom" }),
|
|
3601
|
+
...renameRules(pluginReactHooks.configs.recommended.rules, { "@eslint-react": "react-hooks" }),
|
|
3602
|
+
...renameRules(plugins["@eslint-react/hooks-extra"].configs.recommended.rules, { "@eslint-react": "react-hooks-extra" }),
|
|
3603
|
+
...renameRules(plugins["@eslint-react/naming-convention"].configs.recommended.rules, { "@eslint-react": "react-naming-convention" }),
|
|
3604
|
+
...renameRules(plugins["@eslint-react/web-api"].configs.recommended.rules, { "@eslint-react": "react-web-api" }),
|
|
3586
3605
|
"react/no-prop-types": "error",
|
|
3587
3606
|
"react-dom/no-unknown-property": "off",
|
|
3588
|
-
"react/avoid-shorthand-boolean": ["error"
|
|
3607
|
+
"react/avoid-shorthand-boolean": ["error"],
|
|
3589
3608
|
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
3590
3609
|
"react-refresh/only-export-components": "warn"
|
|
3591
3610
|
}
|
|
3592
3611
|
},
|
|
3612
|
+
{
|
|
3613
|
+
files: ["src/components/**/*.{ts,tsx}"],
|
|
3614
|
+
rules: {
|
|
3615
|
+
"react-naming-convention/filename": ["warn", { rule: "PascalCase" }]
|
|
3616
|
+
}
|
|
3617
|
+
},
|
|
3618
|
+
{
|
|
3619
|
+
files: ["src/hooks/**/use*.{ts,tsx}"],
|
|
3620
|
+
rules: {
|
|
3621
|
+
"react-naming-convention/filename": ["warn", { rule: "kebab-case" }]
|
|
3622
|
+
}
|
|
3623
|
+
},
|
|
3593
3624
|
{
|
|
3594
3625
|
files: [
|
|
3595
3626
|
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
package/dts/utils.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fork https://github.com/antfu/eslint-config/blob/main/src/utils.ts
|
|
3
|
+
* Rename plugin prefixes in a rule object.
|
|
4
|
+
* Accepts a map of prefixes to rename.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { renameRules } from '@antfu/eslint-config'
|
|
9
|
+
*
|
|
10
|
+
* export default [{
|
|
11
|
+
* rules: renameRules(
|
|
12
|
+
* {
|
|
13
|
+
* '@typescript-eslint/indent': 'error'
|
|
14
|
+
* },
|
|
15
|
+
* { '@typescript-eslint': 'ts' }
|
|
16
|
+
* )
|
|
17
|
+
* }]
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiou/eslint-config",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "eslint config for JW",
|
|
6
6
|
"keywords": [],
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"jsonc-eslint-parser": "^2.4.0",
|
|
69
69
|
"local-pkg": "^0.4.3",
|
|
70
70
|
"yaml-eslint-parser": "^1.3.0",
|
|
71
|
-
"@aiou/eslint-
|
|
72
|
-
"@aiou/eslint-
|
|
71
|
+
"@aiou/eslint-plugin-progress": "0.3.1",
|
|
72
|
+
"@aiou/eslint-ignore": "0.6.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@rollup/plugin-alias": "4.0.3",
|