@itcase/lint 1.0.22 → 1.0.23

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/eslint/index.js CHANGED
@@ -8,8 +8,17 @@ import eslintReact from 'eslint-plugin-react'
8
8
  import eslintReactHooks from 'eslint-plugin-react-hooks'
9
9
  import eslintTypeScript from 'typescript-eslint'
10
10
 
11
- import { eslintStyleObjects, eslintStyleObjectsCustomGroups } from './eslint.styleObjects.js'
12
- import { eslintStyleProps, eslintStylePropsCustomGroups } from './eslint.styleProps.js'
11
+ import {
12
+ sortClasses,
13
+ sortEnums,
14
+ sortInterfaces,
15
+ sortIntersectionTypes,
16
+ sortJSXProps,
17
+ sortMaps,
18
+ sortObjects,
19
+ sortObjectTypes,
20
+ sortUnionTypes,
21
+ } from './perfectionist/index.js'
13
22
 
14
23
  const eslintConfig = [
15
24
  eslintJs.configs.recommended,
@@ -42,7 +51,7 @@ const eslintConfig = [
42
51
  '@typescript-eslint/no-explicit-any': 'off',
43
52
  // Sometimes you need an empty one, for example when extends
44
53
  '@typescript-eslint/no-empty-object-type': 'off',
45
- "@typescript-eslint/no-unused-expressions": 'off',
54
+ '@typescript-eslint/no-unused-expressions': 'off',
46
55
 
47
56
  // react
48
57
  // TODO: make rule "react/prop-types" as error only for JS(x) files
@@ -59,151 +68,22 @@ const eslintConfig = [
59
68
  'object-shorthand': ['warn', 'consistent'],
60
69
 
61
70
  // Class
62
- 'perfectionist/sort-classes': [
63
- 'error',
64
- {
65
- type: 'natural',
66
- order: 'asc',
67
- groups: [
68
- 'top',
69
- 'index-signature',
70
- 'static-property',
71
- 'private-property',
72
- 'property',
73
- 'constructor',
74
- 'static-method',
75
- 'private-method',
76
- 'get-method',
77
- 'set-method',
78
- 'method',
79
- ],
80
- customGroups: [
81
- {
82
- groupName: 'top',
83
- elementNamePattern: 'id',
84
- },
85
- ],
86
- },
87
- ],
88
-
71
+ 'perfectionist/sort-classes': sortClasses,
89
72
  // Objects
90
- 'perfectionist/sort-objects': [
91
- 'error',
92
- {
93
- type: 'natural',
94
- order: 'asc',
95
- groups: [
96
- 'isMobile',
97
- 'isTablet',
98
- 'isDesktop',
99
- 'id',
100
- 'children',
101
- ...eslintStyleObjects,
102
- 'device',
103
- 'is',
104
- 'unknown',
105
- 'callback',
106
- ],
107
- customGroups: {
108
- id: 'id',
109
- children: 'children',
110
- isMobile: 'isMobile*',
111
- isTablet: 'isTablet*',
112
- isDesktop: 'isDesktop*',
113
- ...eslintStyleObjectsCustomGroups,
114
- device: 'device',
115
- is: 'is*',
116
- callback: 'on*',
117
- },
118
- },
119
- ],
120
-
73
+ 'perfectionist/sort-objects': sortObjects,
74
+ 'perfectionist/sort-object-types': sortObjectTypes,
121
75
  // Props
122
- 'perfectionist/sort-jsx-props': [
123
- 'error',
124
- {
125
- type: 'natural',
126
- order: 'asc',
127
- groups: [
128
- 'className',
129
- 'key',
130
- 'ref',
131
- 'name',
132
- ...eslintStyleProps,
133
- 'shorthand',
134
- 'unknown',
135
- 'multiline',
136
- 'is',
137
- 'set',
138
- 'callback',
139
- ],
140
- customGroups: {
141
- className: 'className',
142
- key: 'key',
143
- ref: 'ref',
144
- name: 'name',
145
- ...eslintStylePropsCustomGroups,
146
- is: 'is*',
147
- callback: 'on*',
148
- set: ['set*'],
149
- },
150
- },
151
- ],
152
-
153
- // Types
154
- 'perfectionist/sort-object-types': [
155
- 'error',
156
- {
157
- type: 'natural',
158
- order: 'asc',
159
- groups: ['top'],
160
- customGroups: { top: 'id' },
161
- },
162
- ],
163
-
76
+ 'perfectionist/sort-jsx-props': sortJSXProps,
164
77
  // Interfaces
165
- 'perfectionist/sort-interfaces': [
166
- 'error',
167
- {
168
- type: 'natural',
169
- order: 'asc',
170
- groups: ['top', 'unknown', 'is', 'callback', 'set'],
171
- customGroups: {
172
- top: ['id', 'Id'],
173
- is: 'is*',
174
- callback: 'on*',
175
- set: ['set*'],
176
- },
177
- },
178
- ],
78
+ 'perfectionist/sort-interfaces': sortInterfaces,
179
79
 
180
80
  // Union types
181
- 'perfectionist/sort-union-types': [
182
- 'error',
183
- {
184
- type: 'natural',
185
- order: 'asc',
186
- groups: [
187
- 'conditional',
188
- 'function',
189
- 'import',
190
- 'keyword',
191
- 'literal',
192
- 'named',
193
- 'object',
194
- 'operator',
195
- 'tuple',
196
- 'union',
197
- 'nullish',
198
- 'unknown',
199
- ],
200
- },
201
- ],
81
+ 'perfectionist/sort-union-types': sortUnionTypes,
202
82
 
203
83
  // Maps, Enum, Intersection types
204
- 'perfectionist/sort-maps': ['error', { type: 'natural', order: 'asc' }],
205
- 'perfectionist/sort-enums': ['error', { type: 'natural', order: 'asc' }],
206
- 'perfectionist/sort-intersection-types': ['error', { type: 'natural', order: 'asc' }],
84
+ 'perfectionist/sort-maps': sortMaps,
85
+ 'perfectionist/sort-enums': sortEnums,
86
+ 'perfectionist/sort-intersection-types': sortIntersectionTypes,
207
87
  },
208
88
  },
209
89
  ...eslintMarkdown.configs.recommended,
@@ -0,0 +1,21 @@
1
+ import { sortClasses } from './sortClasses.js'
2
+ import { sortEnums } from './sortEnums.js'
3
+ import { sortInterfaces } from './sortInterfaces.js'
4
+ import { sortIntersectionTypes } from './sortIntersectionTypes.js'
5
+ import { sortJSXProps } from './sortJSXProps.js'
6
+ import { sortMaps } from './sortMaps.js'
7
+ import { sortObjects } from './sortObjects.js'
8
+ import { sortObjectTypes } from './sortObjectTypes.js'
9
+ import { sortUnionTypes } from './sortUnionTypes.js'
10
+
11
+ export {
12
+ sortClasses,
13
+ sortEnums,
14
+ sortInterfaces,
15
+ sortIntersectionTypes,
16
+ sortJSXProps,
17
+ sortMaps,
18
+ sortObjects,
19
+ sortObjectTypes,
20
+ sortUnionTypes,
21
+ }
@@ -0,0 +1,28 @@
1
+ const sortClasses = [
2
+ 'error',
3
+ {
4
+ type: 'natural',
5
+ order: 'asc',
6
+ groups: [
7
+ 'top',
8
+ 'index-signature',
9
+ 'static-property',
10
+ 'private-property',
11
+ 'property',
12
+ 'constructor',
13
+ 'static-method',
14
+ 'private-method',
15
+ 'get-method',
16
+ 'set-method',
17
+ 'method',
18
+ ],
19
+ customGroups: [
20
+ {
21
+ groupName: 'top',
22
+ elementNamePattern: 'id',
23
+ },
24
+ ],
25
+ },
26
+ ]
27
+
28
+ export { sortClasses }
@@ -0,0 +1,3 @@
1
+ const sortEnums = ['error', { type: 'natural', order: 'asc' }]
2
+
3
+ export { sortEnums }
@@ -0,0 +1,16 @@
1
+ const sortInterfaces = [
2
+ 'error',
3
+ {
4
+ type: 'natural',
5
+ order: 'asc',
6
+ groups: ['top', 'unknown', 'is', 'callback', 'set'],
7
+ customGroups: {
8
+ top: ['id', 'Id'],
9
+ is: 'is*',
10
+ callback: 'on*',
11
+ set: ['set*'],
12
+ },
13
+ },
14
+ ]
15
+
16
+ export { sortInterfaces }
@@ -0,0 +1,3 @@
1
+ const sortIntersectionTypes = ['error', { type: 'natural', order: 'asc' }]
2
+
3
+ export { sortIntersectionTypes }
@@ -0,0 +1,34 @@
1
+ import { eslintStyleProps, eslintStylePropsCustomGroups } from './../eslint.styleProps.js'
2
+
3
+ const sortJSXProps = [
4
+ 'error',
5
+ {
6
+ type: 'natural',
7
+ order: 'asc',
8
+ groups: [
9
+ 'className',
10
+ 'key',
11
+ 'ref',
12
+ 'name',
13
+ ...eslintStyleProps,
14
+ 'shorthand',
15
+ 'unknown',
16
+ 'multiline',
17
+ 'is',
18
+ 'set',
19
+ 'callback',
20
+ ],
21
+ customGroups: {
22
+ className: 'className',
23
+ key: 'key',
24
+ ref: 'ref',
25
+ name: 'name',
26
+ ...eslintStylePropsCustomGroups,
27
+ is: 'is*',
28
+ callback: 'on*',
29
+ set: ['set*'],
30
+ },
31
+ },
32
+ ]
33
+
34
+ export { sortJSXProps }
@@ -0,0 +1,3 @@
1
+ const sortMaps = ['error', { type: 'natural', order: 'asc' }]
2
+
3
+ export { sortMaps }
@@ -0,0 +1,11 @@
1
+ const sortObjectTypes = [
2
+ 'error',
3
+ {
4
+ type: 'natural',
5
+ order: 'asc',
6
+ groups: ['top'],
7
+ customGroups: { top: 'id' },
8
+ },
9
+ ]
10
+
11
+ export { sortObjectTypes }
@@ -0,0 +1,34 @@
1
+ import { eslintStyleObjects, eslintStyleObjectsCustomGroups } from './../eslint.styleObjects.js'
2
+
3
+ const sortObjects = [
4
+ 'error',
5
+ {
6
+ type: 'natural',
7
+ order: 'asc',
8
+ groups: [
9
+ 'isMobile',
10
+ 'isTablet',
11
+ 'isDesktop',
12
+ 'id',
13
+ 'children',
14
+ ...eslintStyleObjects,
15
+ 'device',
16
+ 'is',
17
+ 'unknown',
18
+ 'callback',
19
+ ],
20
+ customGroups: {
21
+ id: 'id',
22
+ children: 'children',
23
+ isMobile: 'isMobile*',
24
+ isTablet: 'isTablet*',
25
+ isDesktop: 'isDesktop*',
26
+ ...eslintStyleObjectsCustomGroups,
27
+ device: 'device',
28
+ is: 'is*',
29
+ callback: 'on*',
30
+ },
31
+ },
32
+ ]
33
+
34
+ export { sortObjects }
@@ -0,0 +1,22 @@
1
+ const sortUnionTypes = [
2
+ 'error',
3
+ {
4
+ type: 'natural',
5
+ order: 'asc',
6
+ groups: [
7
+ 'conditional',
8
+ 'function',
9
+ 'import',
10
+ 'keyword',
11
+ 'literal',
12
+ 'named',
13
+ 'object',
14
+ 'operator',
15
+ 'tuple',
16
+ 'union',
17
+ 'nullish',
18
+ 'unknown',
19
+ ],
20
+ },
21
+ ]
22
+ export { sortUnionTypes }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/lint",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "author": "ITCase",
5
5
  "description": "Code style linter configuration presets",
6
6
  "engines": {
@@ -20,7 +20,10 @@
20
20
  "files": [
21
21
  "eslint",
22
22
  "eslint/mobx",
23
+ "perfectionist",
23
24
  "prettier",
25
+ "react-native",
26
+ "storybook",
24
27
  "stylelint",
25
28
  "README.md"
26
29
  ],