@cenk1cenk2/eslint-config 2.4.0 → 2.5.0

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,10 @@
1
+ # [2.5.0](https://github.com/cenk1cenk2/eslint-config/compare/v2.4.0...v2.5.0) (2022-02-01)
2
+
3
+
4
+ ### Features
5
+
6
+ * autoresolve typescript paths ([6fa8fcf](https://github.com/cenk1cenk2/eslint-config/commit/6fa8fcfed10a7dc7a4461ace7416f96e5088a3b9))
7
+
1
8
  # [2.4.0](https://github.com/cenk1cenk2/eslint-config/compare/v2.3.4...v2.4.0) (2022-01-31)
2
9
 
3
10
 
@@ -0,0 +1,67 @@
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.map((path) => {
31
+ return [
32
+ {
33
+ pattern: `${path}/**`,
34
+ group: 'internal'
35
+ },
36
+
37
+ {
38
+ pattern: `${path}`,
39
+ group: 'internal'
40
+ }
41
+ ]
42
+ }),
43
+ ...tsConfigPaths.map((path) => {
44
+ return [
45
+ {
46
+ pattern: `${path}`,
47
+ group: 'internal'
48
+ }
49
+ ]
50
+ })
51
+ ],
52
+ pathGroupsExcludedImportTypes: [ 'builtin' ],
53
+ groups: [
54
+ [ 'builtin', 'external' ],
55
+ [ 'internal', 'index', 'parent', 'sibling' ]
56
+ ],
57
+ 'newlines-between': 'always',
58
+ alphabetize: {
59
+ order: 'asc',
60
+ caseInsensitive: true
61
+ }
62
+ }
63
+ ]
64
+ }
65
+ }
66
+
67
+ 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.0",
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