@itcase/lint 1.0.25 → 1.0.27
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 +1 -1
- package/eslint/perfectionist/sortInterfaces.js +9 -7
- package/eslint/perfectionist/sortJSXProps.js +8 -5
- package/eslint/perfectionist/sortObjectTypes.js +5 -2
- package/eslint/perfectionist/sortObjects.js +12 -8
- package/eslint/react-native/index.js +1 -1
- package/eslint/utils.js +25 -0
- package/package.json +1 -1
- package/eslint/utils/generateCustomGroups.js +0 -11
package/README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wrapArrayWithCaretAndDollarAnchors } from '../utils.js'
|
|
2
2
|
|
|
3
3
|
// In what order they are written, that’s how they will be sorted
|
|
4
4
|
// В каком порядке они записаны, так они и будут отсортированы
|
|
5
|
-
const groups = ['
|
|
5
|
+
const groups = ['id', 'unknown', 'is', 'callback', 'set']
|
|
6
6
|
|
|
7
7
|
const customRulesForGroups = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
set: ['set*'],
|
|
8
|
+
is: '^is.*',
|
|
9
|
+
callback: '^on.*',
|
|
10
|
+
set: '^set.*',
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
const sortInterfaces = [
|
|
@@ -17,7 +16,10 @@ const sortInterfaces = [
|
|
|
17
16
|
type: 'natural',
|
|
18
17
|
order: 'asc',
|
|
19
18
|
groups: groups,
|
|
20
|
-
customGroups:
|
|
19
|
+
customGroups: {
|
|
20
|
+
...wrapArrayWithCaretAndDollarAnchors(groups),
|
|
21
|
+
...customRulesForGroups,
|
|
22
|
+
},
|
|
21
23
|
},
|
|
22
24
|
]
|
|
23
25
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { wrapArrayWithCaretAndDollarAnchors } from '../utils.js'
|
|
1
2
|
import { eslintStyleProps } from './../eslint.styleProps.js'
|
|
2
|
-
import { generateCustomGroups } from './../utils/generateCustomGroups.js'
|
|
3
3
|
|
|
4
4
|
// In what order they are written, that’s how they will be sorted
|
|
5
5
|
// В каком порядке они записаны, так они и будут отсортированы
|
|
@@ -18,9 +18,9 @@ const groups = [
|
|
|
18
18
|
]
|
|
19
19
|
|
|
20
20
|
const customRulesForGroups = {
|
|
21
|
-
is: 'is
|
|
22
|
-
callback: 'on
|
|
23
|
-
set:
|
|
21
|
+
is: '^is.*',
|
|
22
|
+
callback: '^on.*',
|
|
23
|
+
set: '^set.*',
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const sortJSXProps = [
|
|
@@ -29,7 +29,10 @@ const sortJSXProps = [
|
|
|
29
29
|
type: 'natural',
|
|
30
30
|
order: 'asc',
|
|
31
31
|
groups: groups,
|
|
32
|
-
customGroups:
|
|
32
|
+
customGroups: {
|
|
33
|
+
...wrapArrayWithCaretAndDollarAnchors(groups),
|
|
34
|
+
...customRulesForGroups,
|
|
35
|
+
},
|
|
33
36
|
},
|
|
34
37
|
]
|
|
35
38
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wrapArrayWithCaretAndDollarAnchors } from '../utils.js'
|
|
2
2
|
|
|
3
3
|
// In what order they are written, that’s how they will be sorted
|
|
4
4
|
// В каком порядке они записаны, так они и будут отсортированы
|
|
@@ -12,7 +12,10 @@ const sortObjectTypes = [
|
|
|
12
12
|
type: 'natural',
|
|
13
13
|
order: 'asc',
|
|
14
14
|
groups: groups,
|
|
15
|
-
customGroups:
|
|
15
|
+
customGroups: {
|
|
16
|
+
...wrapArrayWithCaretAndDollarAnchors(groups),
|
|
17
|
+
...customRulesForGroups,
|
|
18
|
+
},
|
|
16
19
|
},
|
|
17
20
|
]
|
|
18
21
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wrapArrayWithCaretAndDollarAnchors } from '../utils.js'
|
|
2
2
|
import { eslintStyleObjects } from './../eslint.styleObjects.js'
|
|
3
3
|
|
|
4
4
|
// In what order they are written, that’s how they will be sorted
|
|
5
5
|
// В каком порядке они записаны, так они и будут отсортированы
|
|
6
6
|
const groups = [
|
|
7
|
+
'id',
|
|
7
8
|
'isMobile',
|
|
8
9
|
'isTablet',
|
|
9
10
|
'isDesktop',
|
|
10
|
-
'id',
|
|
11
11
|
'children',
|
|
12
12
|
...eslintStyleObjects,
|
|
13
13
|
'device',
|
|
@@ -17,11 +17,12 @@ const groups = [
|
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
const customRulesForGroups = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
id: '^id$',
|
|
21
|
+
isMobile: '^isMobile.*',
|
|
22
|
+
isTablet: '^isTablet.*',
|
|
23
|
+
isDesktop: '^isDesktop.*',
|
|
24
|
+
is: '^is.*',
|
|
25
|
+
callback: '^on.*',
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const sortObjects = [
|
|
@@ -30,7 +31,10 @@ const sortObjects = [
|
|
|
30
31
|
type: 'natural',
|
|
31
32
|
order: 'asc',
|
|
32
33
|
groups: groups,
|
|
33
|
-
customGroups:
|
|
34
|
+
customGroups: {
|
|
35
|
+
...wrapArrayWithCaretAndDollarAnchors(groups),
|
|
36
|
+
...customRulesForGroups,
|
|
37
|
+
},
|
|
34
38
|
},
|
|
35
39
|
]
|
|
36
40
|
|
|
@@ -11,7 +11,7 @@ export default [
|
|
|
11
11
|
rules: {
|
|
12
12
|
'react-native/no-unused-styles': 'error',
|
|
13
13
|
'react-native/split-platform-components': 'error',
|
|
14
|
-
'react-native/no-inline-styles': '
|
|
14
|
+
'react-native/no-inline-styles': 'warn',
|
|
15
15
|
'react-native/no-color-literals': 'error',
|
|
16
16
|
'react-native/no-raw-text': 'error',
|
|
17
17
|
'react-native/no-single-element-style-arrays': 'error',
|
package/eslint/utils.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const validateArray = (arr) => {
|
|
2
|
+
if (!Array.isArray(arr) || !arr.every((str) => typeof str === 'string')) {
|
|
3
|
+
throw new Error('Input must be an array of strings')
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const wrapArrayWithCaretAndDollarAnchors = (arr) => {
|
|
8
|
+
validateArray(arr)
|
|
9
|
+
|
|
10
|
+
return arr.reduce((acc, str) => {
|
|
11
|
+
acc[str] = `^${str}$`
|
|
12
|
+
return acc
|
|
13
|
+
}, {})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const wrapArrayWithCaretAndWildcard = (arr) => {
|
|
17
|
+
validateArray(arr)
|
|
18
|
+
|
|
19
|
+
return arr.reduce((acc, str) => {
|
|
20
|
+
acc[str] = `^${str}.*`
|
|
21
|
+
return acc
|
|
22
|
+
}, {})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { wrapArrayWithCaretAndDollarAnchors, wrapArrayWithCaretAndWildcard }
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const generateCustomGroups = (groups, customRulesForGroups = {}) => {
|
|
2
|
-
const defaultRulesForGroups = groups.reduce((acc, group) => {
|
|
3
|
-
acc[group] = group
|
|
4
|
-
return acc
|
|
5
|
-
}, {})
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
...defaultRulesForGroups,
|
|
9
|
-
...customRulesForGroups,
|
|
10
|
-
}
|
|
11
|
-
}
|