@cenk1cenk2/eslint-config 2.4.0 → 2.5.3

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 CHANGED
@@ -1,3 +1,31 @@
1
+ ## [2.5.3](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.2...v2.5.3) (2022-02-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * allowed groups ([2e5a615](https://github.com/cenk1cenk2/eslint-config/commit/2e5a615d1918059f52f1f2bc29e709779194f844))
7
+
8
+ ## [2.5.2](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.1...v2.5.2) (2022-02-01)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * use flat arrays ([c78b8c6](https://github.com/cenk1cenk2/eslint-config/commit/c78b8c6b8d98e44b1c2cf0c6aa8a7f088c285e06))
14
+
15
+ ## [2.5.1](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.0...v2.5.1) (2022-02-01)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * try with flatmap ([956c3a4](https://github.com/cenk1cenk2/eslint-config/commit/956c3a496ea786540377655af3d4ec8a71622470))
21
+
22
+ # [2.5.0](https://github.com/cenk1cenk2/eslint-config/compare/v2.4.0...v2.5.0) (2022-02-01)
23
+
24
+
25
+ ### Features
26
+
27
+ * autoresolve typescript paths ([6fa8fcf](https://github.com/cenk1cenk2/eslint-config/commit/6fa8fcfed10a7dc7a4461ace7416f96e5088a3b9))
28
+
1
29
  # [2.4.0](https://github.com/cenk1cenk2/eslint-config/compare/v2.3.4...v2.4.0) (2022-01-31)
2
30
 
3
31
 
@@ -0,0 +1,71 @@
1
+ const { loadTsConfig } = require('load-tsconfig')
2
+
3
+ /**
4
+ * @param {{ paths?: string[] tsconfig?: string, tsconfigDir?: string}} options
5
+ * @returns {import("eslint").Linter.Config['rules']}
6
+ */
7
+ function generateImportPluginGroupCases (options) {
8
+ const defaults = [ '@cenk1cenk2', '@cenk1cenk2-*' ]
9
+
10
+ options.paths = options.paths ? options.paths.push(...defaults) : defaults
11
+
12
+ /** @type {string[]} */
13
+ let tsConfigPaths = []
14
+
15
+ if (options.tsconfigDir) {
16
+ const tsconfig = loadTsConfig(options.tsconfigDir, options.tsconfig)
17
+
18
+ if (tsconfig.data?.compilerOptions?.paths) {
19
+ tsConfigPaths = Object.keys(tsconfig.data.compilerOptions.paths).map((path) => {
20
+ return path.replace('*', '**')
21
+ })
22
+ }
23
+ }
24
+
25
+ return {
26
+ 'import/order': [
27
+ 'error',
28
+ {
29
+ pathGroups: [
30
+ ...options.paths.reduce((o, path) => {
31
+ return [
32
+ ...o,
33
+
34
+ {
35
+ pattern: `${path}/**`,
36
+ group: 'index'
37
+ },
38
+
39
+ {
40
+ pattern: `${path}`,
41
+ group: 'index'
42
+ }
43
+ ]
44
+ }, []),
45
+ ...tsConfigPaths.reduce((o, path) => {
46
+ return [
47
+ ...o,
48
+
49
+ {
50
+ pattern: `${path}`,
51
+ group: 'index'
52
+ }
53
+ ]
54
+ }, [])
55
+ ],
56
+ pathGroupsExcludedImportTypes: [ 'builtin' ],
57
+ groups: [
58
+ [ 'builtin', 'external' ],
59
+ [ 'index', 'parent', 'sibling' ]
60
+ ],
61
+ 'newlines-between': 'always',
62
+ alphabetize: {
63
+ order: 'asc',
64
+ caseInsensitive: true
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ }
70
+
71
+ module.exports = generateImportPluginGroupCases
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/eslint-config",
3
- "version": "2.4.0",
3
+ "version": "2.5.3",
4
4
  "description": "Eslint configuration for my taste.",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/cenk1cenk2/eslint-config",
@@ -24,9 +24,9 @@
24
24
  ]
25
25
  },
26
26
  "peerDependencies": {
27
- "eslint": ">= 8",
28
27
  "@nuxtjs/eslint-config": ">= 7",
29
28
  "@nuxtjs/eslint-config-typescript": ">= 7",
29
+ "eslint": ">= 8",
30
30
  "eslint-config-react": ">= 1",
31
31
  "eslint-plugin-react-hooks": ">= 4"
32
32
  },
@@ -47,18 +47,19 @@
47
47
  "dependencies": {
48
48
  "@typescript-eslint/eslint-plugin": "^5.9.0",
49
49
  "@typescript-eslint/parser": "^5.9.0",
50
- "eslint-plugin-import": "^2.25.4"
50
+ "eslint-plugin-import": "^2.25.4",
51
+ "load-tsconfig": "^0.2.3"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@cenk1cenk2/cz-cc": "^1.4.11",
54
- "eslint": "^8.8.0",
55
- "lint-staged": "^12.1.7",
56
- "prettier": "^2.5.1",
57
- "simple-git-hooks": "^2.7.0",
58
55
  "@nuxtjs/eslint-config": "^8.0.0",
59
56
  "@nuxtjs/eslint-config-typescript": "^8.0.0",
57
+ "eslint": "^8.8.0",
60
58
  "eslint-config-react": "^1.1.7",
61
- "eslint-plugin-react-hooks": "^4.3.0"
59
+ "eslint-plugin-react-hooks": "^4.3.0",
60
+ "lint-staged": "^12.1.7",
61
+ "prettier": "^2.5.1",
62
+ "simple-git-hooks": "^2.7.0"
62
63
  },
63
64
  "config": {
64
65
  "commitizen": {
package/import-helper.js DELETED
@@ -1,36 +0,0 @@
1
- /**
2
- * @param {string[]} cases
3
- * @returns {import("eslint").Linter.Config['rules']}
4
- */
5
- function generateImportPluginGroupCases (cases) {
6
- return {
7
- 'import/order': [
8
- 'error',
9
- {
10
- pathGroups: [
11
- {
12
- pattern: `@{${cases.join(',')}}/**`,
13
- group: 'index'
14
- },
15
-
16
- {
17
- pattern: `@{${cases.join(',')}}`,
18
- group: 'index'
19
- }
20
- ],
21
- pathGroupsExcludedImportTypes: [ 'builtin' ],
22
- groups: [
23
- [ 'builtin', 'external' ],
24
- [ 'index', 'parent', 'sibling' ]
25
- ],
26
- 'newlines-between': 'always',
27
- alphabetize: {
28
- order: 'asc',
29
- caseInsensitive: true
30
- }
31
- }
32
- ]
33
- }
34
- }
35
-
36
- module.exports = generateImportPluginGroupCases