@slashnephy/eslint-config 3.0.478 → 3.0.479

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slashnephy/eslint-config",
3
- "version": "3.0.478",
3
+ "version": "3.0.479",
4
4
  "keywords": [
5
5
  "eslint",
6
6
  "eslintconfig"
@@ -35,6 +35,7 @@
35
35
  "eslint-plugin-jsx-a11y-x": "0.2.0",
36
36
  "eslint-plugin-n": "18.3.0",
37
37
  "eslint-plugin-package-json": "1.10.0",
38
+ "eslint-plugin-perfectionist": "5.12.1",
38
39
  "eslint-plugin-promise": "7.3.0",
39
40
  "eslint-plugin-react-hooks": "7.1.1",
40
41
  "eslint-plugin-react-refresh": "0.5.7",
@@ -2,13 +2,14 @@ import eslintReact from '@eslint-react/eslint-plugin';
2
2
  import stylisticPlugin from '@stylistic/eslint-plugin';
3
3
  import { defineConfig } from 'eslint/config';
4
4
  import jsxA11yX from 'eslint-plugin-jsx-a11y-x';
5
+ import perfectionistPlugin from 'eslint-plugin-perfectionist';
5
6
  import reactHooksPlugin from 'eslint-plugin-react-hooks';
6
7
  import globals from 'globals';
7
8
  export const react = defineConfig(
8
9
  // eslint-react(型チェック付きルール)
9
10
  // eslint-plugin-react は ESLint v10 で削除された context.getFilename() を呼ぶため
10
11
  // ロード時にクラッシュする (jsx-eslint/eslint-plugin-react#3977 が open のまま)。
11
- // correctness 系のルールは eslint-react が、JSX の書式系は @stylistic が肩代わりする。
12
+ // correctness 系のルールは eslint-react が、JSX の書式系は @stylistic が、props の並び替えは perfectionist が肩代わりする。
12
13
  {
13
14
  name: '@eslint-react/eslint-plugin',
14
15
  files: ['**/*.{jsx,tsx}'],
@@ -47,14 +48,56 @@ export const react = defineConfig(
47
48
  ],
48
49
  // コンポーネント名を PascalCase に強制
49
50
  '@stylistic/jsx-pascal-case': 'error',
50
- // props を並び替える
51
- '@stylistic/jsx-sort-props': [
51
+ },
52
+ },
53
+ // props の並び替え
54
+ // @stylistic/jsx-sort-props は deprecated になり、移行先として perfectionist の sort-jsx-props が案内されている。
55
+ // 旧設定 (reservedFirst / shorthandFirst / multiline: 'last' / callbacksLast) と同じ並びをグループで再現する。
56
+ {
57
+ name: 'eslint-plugin-perfectionist (jsx)',
58
+ files: ['**/*.{jsx,tsx}'],
59
+ plugins: {
60
+ perfectionist: perfectionistPlugin,
61
+ },
62
+ rules: {
63
+ 'perfectionist/sort-jsx-props': [
52
64
  'error',
53
65
  {
54
- callbacksLast: true,
55
- shorthandFirst: true,
56
- multiline: 'last',
57
- reservedFirst: true,
66
+ // 旧ルールは文字コード順 (`<` 比較) で並べていたため、localeCompare (大文字小文字を辞書順に混ぜる) ではなく
67
+ // ASCII を文字コード順に並べた alphabet で比較する
68
+ type: 'custom',
69
+ alphabet: String.fromCharCode(...Array.from({ length: 128 }, (_, i) => i)),
70
+ ignoreCase: false,
71
+ customGroups: [
72
+ {
73
+ groupName: 'reserved',
74
+ elementNamePattern: '^(children|dangerouslySetInnerHTML|key|ref)$',
75
+ },
76
+ // 先に一致したカスタムグループが採用されるため、修飾子付きのコールバックを先に置く
77
+ {
78
+ groupName: 'shorthand-callback',
79
+ elementNamePattern: '^on[A-Z]',
80
+ modifiers: ['shorthand'],
81
+ },
82
+ {
83
+ groupName: 'multiline-callback',
84
+ elementNamePattern: '^on[A-Z]',
85
+ modifiers: ['multiline'],
86
+ },
87
+ {
88
+ groupName: 'callback',
89
+ elementNamePattern: '^on[A-Z]',
90
+ },
91
+ ],
92
+ groups: [
93
+ 'reserved',
94
+ 'shorthand-prop',
95
+ 'prop',
96
+ 'multiline-prop',
97
+ 'shorthand-callback',
98
+ 'callback',
99
+ 'multiline-callback',
100
+ ],
58
101
  },
59
102
  ],
60
103
  },
@@ -2,6 +2,7 @@ import eslintReact from '@eslint-react/eslint-plugin'
2
2
  import stylisticPlugin from '@stylistic/eslint-plugin'
3
3
  import { defineConfig } from 'eslint/config'
4
4
  import jsxA11yX from 'eslint-plugin-jsx-a11y-x'
5
+ import perfectionistPlugin from 'eslint-plugin-perfectionist'
5
6
  import reactHooksPlugin from 'eslint-plugin-react-hooks'
6
7
  import globals from 'globals'
7
8
 
@@ -9,7 +10,7 @@ export const react = defineConfig(
9
10
  // eslint-react(型チェック付きルール)
10
11
  // eslint-plugin-react は ESLint v10 で削除された context.getFilename() を呼ぶため
11
12
  // ロード時にクラッシュする (jsx-eslint/eslint-plugin-react#3977 が open のまま)。
12
- // correctness 系のルールは eslint-react が、JSX の書式系は @stylistic が肩代わりする。
13
+ // correctness 系のルールは eslint-react が、JSX の書式系は @stylistic が、props の並び替えは perfectionist が肩代わりする。
13
14
  {
14
15
  name: '@eslint-react/eslint-plugin',
15
16
  files: ['**/*.{jsx,tsx}'],
@@ -48,14 +49,56 @@ export const react = defineConfig(
48
49
  ],
49
50
  // コンポーネント名を PascalCase に強制
50
51
  '@stylistic/jsx-pascal-case': 'error',
51
- // props を並び替える
52
- '@stylistic/jsx-sort-props': [
52
+ },
53
+ },
54
+ // props の並び替え
55
+ // @stylistic/jsx-sort-props は deprecated になり、移行先として perfectionist の sort-jsx-props が案内されている。
56
+ // 旧設定 (reservedFirst / shorthandFirst / multiline: 'last' / callbacksLast) と同じ並びをグループで再現する。
57
+ {
58
+ name: 'eslint-plugin-perfectionist (jsx)',
59
+ files: ['**/*.{jsx,tsx}'],
60
+ plugins: {
61
+ perfectionist: perfectionistPlugin,
62
+ },
63
+ rules: {
64
+ 'perfectionist/sort-jsx-props': [
53
65
  'error',
54
66
  {
55
- callbacksLast: true,
56
- shorthandFirst: true,
57
- multiline: 'last',
58
- reservedFirst: true,
67
+ // 旧ルールは文字コード順 (`<` 比較) で並べていたため、localeCompare (大文字小文字を辞書順に混ぜる) ではなく
68
+ // ASCII を文字コード順に並べた alphabet で比較する
69
+ type: 'custom',
70
+ alphabet: String.fromCharCode(...Array.from({ length: 128 }, (_, i) => i)),
71
+ ignoreCase: false,
72
+ customGroups: [
73
+ {
74
+ groupName: 'reserved',
75
+ elementNamePattern: '^(children|dangerouslySetInnerHTML|key|ref)$',
76
+ },
77
+ // 先に一致したカスタムグループが採用されるため、修飾子付きのコールバックを先に置く
78
+ {
79
+ groupName: 'shorthand-callback',
80
+ elementNamePattern: '^on[A-Z]',
81
+ modifiers: ['shorthand'],
82
+ },
83
+ {
84
+ groupName: 'multiline-callback',
85
+ elementNamePattern: '^on[A-Z]',
86
+ modifiers: ['multiline'],
87
+ },
88
+ {
89
+ groupName: 'callback',
90
+ elementNamePattern: '^on[A-Z]',
91
+ },
92
+ ],
93
+ groups: [
94
+ 'reserved',
95
+ 'shorthand-prop',
96
+ 'prop',
97
+ 'multiline-prop',
98
+ 'shorthand-callback',
99
+ 'callback',
100
+ 'multiline-callback',
101
+ ],
59
102
  },
60
103
  ],
61
104
  },