@mouse_484/eslint-config 4.4.12 → 5.0.0

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mouse_484/eslint-config",
3
3
  "type": "module",
4
- "version": "4.4.12",
4
+ "version": "5.0.0",
5
5
  "author": "mouse_484",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/mouse484/config/tree/main/packages/eslint",
@@ -0,0 +1,64 @@
1
+ import { GLOB_JSX, GLOB_TSX } from '@antfu/eslint-config'
2
+ import { createConfigs } from '../lib/factory.js'
3
+
4
+ const BOOLEAN_NAME_PATTERN = '^(is|has).+'
5
+
6
+ export default createConfigs({
7
+ name: 'perfectionist',
8
+ configs: [
9
+ {
10
+ name: 'jsx',
11
+ files: [GLOB_JSX, GLOB_TSX],
12
+ rules: {
13
+ 'perfectionist/sort-jsx-props': [
14
+ 'error',
15
+ {
16
+ type: 'natural',
17
+ groups: [
18
+ 'primary',
19
+ 'accsessibility',
20
+ 'data-attributes',
21
+ 'style',
22
+ 'unknown',
23
+ 'predicate',
24
+ 'callback',
25
+ ],
26
+ customGroups: [
27
+ {
28
+ groupName: 'primary',
29
+ elementNamePattern: '^(key|ref|id)$',
30
+ },
31
+ {
32
+ groupName: 'accsessibility',
33
+ elementNamePattern: '^(aria|role)-.+',
34
+ },
35
+ {
36
+ groupName: 'data-attributes',
37
+ elementNamePattern: '^data-.+',
38
+ },
39
+ {
40
+ groupName: 'style',
41
+ elementNamePattern: '^(style|className)$',
42
+ },
43
+ {
44
+ groupName: 'predicate',
45
+ anyOf: [
46
+ { elementNamePattern: '^.+ed$' }, // e.g. disabled, checked, selected
47
+ { elementNamePattern: BOOLEAN_NAME_PATTERN },
48
+ { elementValuePattern: '^(true|false)$' },
49
+ { elementValuePattern: '^\!.+' }, // e.g. !important, !isActive
50
+ { elementValuePattern: '.+===?.+' }, // e.g. status === "active"
51
+ { elementValuePattern: BOOLEAN_NAME_PATTERN },
52
+ ],
53
+ },
54
+ {
55
+ groupName: 'callback',
56
+ elementNamePattern: '^on.+',
57
+ },
58
+ ],
59
+ },
60
+ ],
61
+ },
62
+ },
63
+ ],
64
+ })
@@ -1,4 +1,4 @@
1
- import { GLOB_MARKDOWN } from '@antfu/eslint-config'
1
+ import { GLOB_JSX, GLOB_MARKDOWN, GLOB_TSX } from '@antfu/eslint-config'
2
2
  import { createConfigs } from '../lib/factory.js'
3
3
 
4
4
  export default createConfigs({
@@ -45,5 +45,17 @@ export default createConfigs({
45
45
  'style/max-len': 'off',
46
46
  },
47
47
  },
48
+ {
49
+ name: 'jsx',
50
+ files: [GLOB_JSX, GLOB_TSX],
51
+ rules: {
52
+ 'style/jsx-self-closing-comp': 'error',
53
+ 'style/jsx-curly-brace-presence': ['error', {
54
+ propElementValues: 'always',
55
+ props: 'never',
56
+ }],
57
+ 'style/jsx-sort-props': 'off', // perfectionist/sort-jsx-props is used instead
58
+ },
59
+ },
48
60
  ],
49
61
  })
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import antfu from '@antfu/eslint-config'
2
2
  import astro from './configs/astro.js'
3
3
  import base from './configs/base.js'
4
+ import perfectionist from './configs/perfectionist.js'
4
5
  import stylistic from './configs/stylistic.js'
5
6
  import svelte from './configs/svelte.js'
6
7
  import tailwind from './configs/tailwind.js'
@@ -21,6 +22,7 @@ async function mouse(options, ...userConfigs) {
21
22
  // Code style
22
23
  ...stylistic(options),
23
24
  ...unicorn(options),
25
+ ...perfectionist(options),
24
26
  // Language specific
25
27
  ...astro(options),
26
28
  ...svelte(options),