@cenk1cenk2/eslint-config 2.3.4 → 2.5.2

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.2](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.1...v2.5.2) (2022-02-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use flat arrays ([c78b8c6](https://github.com/cenk1cenk2/eslint-config/commit/c78b8c6b8d98e44b1c2cf0c6aa8a7f088c285e06))
7
+
8
+ ## [2.5.1](https://github.com/cenk1cenk2/eslint-config/compare/v2.5.0...v2.5.1) (2022-02-01)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * try with flatmap ([956c3a4](https://github.com/cenk1cenk2/eslint-config/commit/956c3a496ea786540377655af3d4ec8a71622470))
14
+
15
+ # [2.5.0](https://github.com/cenk1cenk2/eslint-config/compare/v2.4.0...v2.5.0) (2022-02-01)
16
+
17
+
18
+ ### Features
19
+
20
+ * autoresolve typescript paths ([6fa8fcf](https://github.com/cenk1cenk2/eslint-config/commit/6fa8fcfed10a7dc7a4461ace7416f96e5088a3b9))
21
+
22
+ # [2.4.0](https://github.com/cenk1cenk2/eslint-config/compare/v2.3.4...v2.4.0) (2022-01-31)
23
+
24
+
25
+ ### Features
26
+
27
+ * adds the import helper ([7d8e040](https://github.com/cenk1cenk2/eslint-config/commit/7d8e040e2d60d8f2d33d09cd5058de6077d3b1da))
28
+
1
29
  ## [2.3.4](https://github.com/cenk1cenk2/eslint-config/compare/v2.3.3...v2.3.4) (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: 'internal'
37
+ },
38
+
39
+ {
40
+ pattern: `${path}`,
41
+ group: 'internal'
42
+ }
43
+ ]
44
+ }, []),
45
+ ...tsConfigPaths.reduce((o, path) => {
46
+ return [
47
+ ...o,
48
+
49
+ {
50
+ pattern: `${path}`,
51
+ group: 'internal'
52
+ }
53
+ ]
54
+ }, [])
55
+ ],
56
+ pathGroupsExcludedImportTypes: [ 'builtin' ],
57
+ groups: [
58
+ [ 'builtin', 'external' ],
59
+ [ 'internal', '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.3.4",
3
+ "version": "2.5.2",
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": {