@cenk1cenk2/eslint-config 2.5.1 → 2.5.5
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/CHANGELOG.md +29 -0
- package/constants.js +3 -0
- package/import-strict.js +12 -4
- package/import.js +43 -36
- package/package.json +1 -1
- package/{import-utils.js → utils.js} +31 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [2.5.5](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.4...v2.5.5) (2022-02-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update ([1ae486c](https://github.com/cenk1cenk2/eslint-config/commit/1ae486c8c3d3f83c6ed1e4e8199b1b41f7b29e2d))
|
|
7
|
+
|
|
8
|
+
## [2.5.4](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.3...v2.5.4) (2022-02-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update function ([1f44e37](https://github.com/cenk1cenk2/eslint-config/commit/1f44e37062366c67ea001c86f8be3ebc4d3f0eb9))
|
|
14
|
+
* update utils ([3beeab4](https://github.com/cenk1cenk2/eslint-config/commit/3beeab4756c1a517e9d65e4137f0e041daee70c1))
|
|
15
|
+
|
|
16
|
+
## [2.5.3](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.2...v2.5.3) (2022-02-01)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* allowed groups ([2e5a615](https://github.com/cenk1cenk2/eslint-config/commit/2e5a615d1918059f52f1f2bc29e709779194f844))
|
|
22
|
+
|
|
23
|
+
## [2.5.2](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.1...v2.5.2) (2022-02-01)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* use flat arrays ([c78b8c6](https://github.com/cenk1cenk2/eslint-config/commit/c78b8c6b8d98e44b1c2cf0c6aa8a7f088c285e06))
|
|
29
|
+
|
|
1
30
|
## [2.5.1](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.0...v2.5.1) (2022-02-01)
|
|
2
31
|
|
|
3
32
|
|
package/constants.js
ADDED
package/import-strict.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
const { ALL_KNOWN_JAVASCRIPT_FILE_EXTENSIONS } = require('./constants')
|
|
2
|
+
|
|
1
3
|
/** @type {import("eslint").Linter.Config} */
|
|
2
4
|
module.exports = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
files: ALL_KNOWN_JAVASCRIPT_FILE_EXTENSIONS,
|
|
8
|
+
plugins: [ 'import' ],
|
|
9
|
+
rules: {
|
|
10
|
+
'import/no-extraneous-dependencies': 'error',
|
|
11
|
+
'import/exports-last': 'error'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
]
|
|
7
15
|
}
|
package/import.js
CHANGED
|
@@ -1,43 +1,50 @@
|
|
|
1
|
+
const { ALL_KNOWN_JAVASCRIPT_FILE_EXTENSIONS } = require('./constants')
|
|
2
|
+
|
|
1
3
|
/** @type {import("eslint").Linter.Config} */
|
|
2
4
|
module.exports = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
files: ALL_KNOWN_JAVASCRIPT_FILE_EXTENSIONS,
|
|
8
|
+
plugins: [ 'import' ],
|
|
9
|
+
rules: {
|
|
10
|
+
'sort-imports': 'off',
|
|
11
|
+
'import/first': 'error',
|
|
12
|
+
'import/newline-after-import': 'error',
|
|
13
|
+
'import/no-duplicates': 'error',
|
|
14
|
+
'import/order': [
|
|
15
|
+
'error',
|
|
13
16
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
pathGroups: [
|
|
18
|
+
{
|
|
19
|
+
pattern: '@{cenk1cenk2,cenk1cenk2-*}/**',
|
|
20
|
+
group: 'index'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pattern: '@{src,interfaces,utils,constants,commands}/**',
|
|
24
|
+
group: 'index'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
pattern: '@{src,interfaces,utils,constants,commands}',
|
|
28
|
+
group: 'index'
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
pathGroupsExcludedImportTypes: [ 'builtin' ],
|
|
32
|
+
groups: [
|
|
33
|
+
[ 'builtin', 'external' ],
|
|
34
|
+
[ 'index', 'parent', 'sibling' ]
|
|
35
|
+
],
|
|
36
|
+
'newlines-between': 'always',
|
|
37
|
+
alphabetize: {
|
|
38
|
+
order: 'asc',
|
|
39
|
+
caseInsensitive: true
|
|
40
|
+
}
|
|
24
41
|
}
|
|
25
42
|
],
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
],
|
|
31
|
-
'newlines-between': 'always',
|
|
32
|
-
alphabetize: {
|
|
33
|
-
order: 'asc',
|
|
34
|
-
caseInsensitive: true
|
|
35
|
-
}
|
|
43
|
+
'import/export': 'error',
|
|
44
|
+
'import/no-extraneous-dependencies': 'error',
|
|
45
|
+
'import/no-self-import': 'error',
|
|
46
|
+
'import/no-useless-path-segments': 'error'
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
'import/no-extraneous-dependencies': 'error',
|
|
40
|
-
'import/no-self-import': 'error',
|
|
41
|
-
'import/no-useless-path-segments': 'error'
|
|
42
|
-
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
43
50
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
const { loadTsConfig } = require('load-tsconfig')
|
|
2
2
|
|
|
3
|
+
const { ALL_KNOWN_JAVASCRIPT_FILE_EXTENSIONS } = require('./constants')
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @param {{ paths?: string[] tsconfig?: string, tsconfigDir?: string}} options
|
|
5
7
|
* @returns {import("eslint").Linter.Config['rules']}
|
|
6
8
|
*/
|
|
7
|
-
function
|
|
9
|
+
function generateImportGroups (options) {
|
|
8
10
|
const defaults = [ '@cenk1cenk2', '@cenk1cenk2-*' ]
|
|
9
11
|
|
|
10
|
-
options.paths = options.paths ? options.paths
|
|
12
|
+
options.paths = Array.isArray(options.paths) ? [ ...options.paths, ...defaults ] : defaults
|
|
11
13
|
|
|
12
14
|
/** @type {string[]} */
|
|
13
15
|
let tsConfigPaths = []
|
|
@@ -27,32 +29,36 @@ function generateImportPluginGroupCases (options) {
|
|
|
27
29
|
'error',
|
|
28
30
|
{
|
|
29
31
|
pathGroups: [
|
|
30
|
-
...options.paths.
|
|
32
|
+
...options.paths.reduce((o, path) => {
|
|
31
33
|
return [
|
|
34
|
+
...o,
|
|
35
|
+
|
|
32
36
|
{
|
|
33
37
|
pattern: `${path}/**`,
|
|
34
|
-
group: '
|
|
38
|
+
group: 'index'
|
|
35
39
|
},
|
|
36
40
|
|
|
37
41
|
{
|
|
38
42
|
pattern: `${path}`,
|
|
39
|
-
group: '
|
|
43
|
+
group: 'index'
|
|
40
44
|
}
|
|
41
45
|
]
|
|
42
|
-
}),
|
|
43
|
-
...tsConfigPaths.
|
|
46
|
+
}, []),
|
|
47
|
+
...tsConfigPaths.reduce((o, path) => {
|
|
44
48
|
return [
|
|
49
|
+
...o,
|
|
50
|
+
|
|
45
51
|
{
|
|
46
52
|
pattern: `${path}`,
|
|
47
|
-
group: '
|
|
53
|
+
group: 'index'
|
|
48
54
|
}
|
|
49
55
|
]
|
|
50
|
-
})
|
|
56
|
+
}, [])
|
|
51
57
|
],
|
|
52
58
|
pathGroupsExcludedImportTypes: [ 'builtin' ],
|
|
53
59
|
groups: [
|
|
54
60
|
[ 'builtin', 'external' ],
|
|
55
|
-
[ '
|
|
61
|
+
[ 'index', 'parent', 'sibling' ]
|
|
56
62
|
],
|
|
57
63
|
'newlines-between': 'always',
|
|
58
64
|
alphabetize: {
|
|
@@ -64,4 +70,18 @@ function generateImportPluginGroupCases (options) {
|
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @param {{ paths?: string[] tsconfig?: string, tsconfigDir?: string}} options
|
|
75
|
+
* @returns {import("eslint").Linter.Config['overrides']}
|
|
76
|
+
*/
|
|
77
|
+
function generateImportGroupsWithOverride (options) {
|
|
78
|
+
return [
|
|
79
|
+
{
|
|
80
|
+
files: ALL_KNOWN_JAVASCRIPT_FILE_EXTENSIONS,
|
|
81
|
+
plugins: [ 'import' ],
|
|
82
|
+
rules: generateImportGroups(options)
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = { generateImportGroups, generateImportGroupsWithOverride }
|