@allthings/eslint-config 0.0.2 → 0.0.4

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 CHANGED
@@ -15,11 +15,11 @@ Add this to your .eslintrc.js
15
15
 
16
16
  ```js
17
17
  module.exports = {
18
- extends: ['@allthings/eslint-config/react'],
18
+ extends: ['@allthings/eslint-config'],
19
19
  }
20
20
  ```
21
21
 
22
- ### Node.js projects
22
+ ### Node.js projects (TODO)
23
23
 
24
24
  ```js
25
25
  module.exports = {
package/default.js CHANGED
@@ -1,12 +1,12 @@
1
1
  module.export = {
2
2
  extends: [
3
- 'plugin:prettier/recommended',
4
3
  'plugin:import/recommended',
5
4
  'plugin:import/typescript',
6
5
  'eslint:recommended',
7
6
  'plugin:@typescript-eslint/eslint-recommended',
8
7
  'plugin:@typescript-eslint/recommended',
9
8
  'plugin:typescript-sort-keys/recommended',
9
+ 'plugin:prettier/recommended',
10
10
  ],
11
11
  plugins: ['typescript-sort-keys', 'simple-import-sort'],
12
12
  rules: {
package/index.js CHANGED
@@ -1 +1,163 @@
1
- module.export = require('react')
1
+ /*
2
+ * @rushstack/eslint-patch is used to include plugins as dev
3
+ * dependencies instead of imposing them as peer dependencies
4
+ *
5
+ * https://www.npmjs.com/package/@rushstack/eslint-patch
6
+ */
7
+ const keptPaths = []
8
+ const sortedPaths = []
9
+ const cwd = process.cwd().replace(/\\/g, '/')
10
+ const originalPaths = require.resolve.paths('eslint-plugin-import')
11
+
12
+ // eslint throws a conflict error when plugins resolve to different
13
+ // locations, since we want to lock our dependencies by default
14
+ // but also need to allow using user dependencies this updates
15
+ // our resolve paths to first check the cwd and iterate to
16
+ // eslint-config-next's dependencies if needed
17
+
18
+ for (let i = originalPaths.length - 1; i >= 0; i--) {
19
+ const currentPath = originalPaths[i]
20
+
21
+ if (currentPath.replace(/\\/g, '/').startsWith(cwd)) {
22
+ sortedPaths.push(currentPath)
23
+ } else {
24
+ keptPaths.unshift(currentPath)
25
+ }
26
+ }
27
+
28
+ // maintain order of node_modules outside cwd
29
+ sortedPaths.push(...keptPaths)
30
+
31
+ const hookPropertyMap = new Map(
32
+ [
33
+ ['eslint-plugin-import', 'eslint-plugin-import'],
34
+ ['eslint-plugin-react', 'eslint-plugin-react'],
35
+ ['eslint-plugin-react-hooks', 'eslint-plugin-react-hooks'],
36
+ ['eslint-plugin-jsx-a11y', 'eslint-plugin-jsx-a11y'],
37
+ [
38
+ 'eslint-plugin-typescript-sort-keys',
39
+ 'eslint-plugin-typescript-sort-keys',
40
+ ],
41
+ ['eslint-plugin-simple-import-sort', 'eslint-plugin-simple-import-sort'],
42
+ ].map(([request, replacement]) => [
43
+ request,
44
+ require.resolve(replacement, { paths: sortedPaths }),
45
+ ]),
46
+ )
47
+
48
+ const mod = require('module')
49
+ const resolveFilename = mod._resolveFilename
50
+ mod._resolveFilename = function (request, parent, isMain, options) {
51
+ const hookResolved = hookPropertyMap.get(request)
52
+ if (hookResolved) {
53
+ request = hookResolved
54
+ }
55
+ return resolveFilename.call(mod, request, parent, isMain, options)
56
+ }
57
+
58
+ require('@rushstack/eslint-patch/modern-module-resolution')
59
+
60
+ module.exports = {
61
+ extends: [
62
+ 'plugin:import/recommended',
63
+ 'plugin:import/typescript',
64
+ 'eslint:recommended',
65
+ 'plugin:@typescript-eslint/eslint-recommended',
66
+ 'plugin:@typescript-eslint/recommended',
67
+ 'plugin:typescript-sort-keys/recommended',
68
+ 'plugin:react/recommended',
69
+ 'plugin:react-hooks/recommended',
70
+ 'plugin:react/jsx-runtime',
71
+ 'plugin:prettier/recommended',
72
+ ],
73
+ plugins: [
74
+ 'import',
75
+ 'react',
76
+ 'react-hooks',
77
+ 'jsx-a11y',
78
+ 'typescript-sort-keys',
79
+ 'simple-import-sort',
80
+ ],
81
+ rules: {
82
+ '@typescript-eslint/naming-convention': [
83
+ 'error',
84
+ {
85
+ custom: {
86
+ match: true,
87
+ regex: '^I[A-Z]',
88
+ },
89
+ format: ['PascalCase'],
90
+ selector: 'interface',
91
+ },
92
+ ],
93
+ '@typescript-eslint/no-unused-vars': 'error',
94
+ 'import/no-anonymous-default-export': [
95
+ 'error',
96
+ {
97
+ allowAnonymousClass: false,
98
+ allowAnonymousFunction: false,
99
+ allowArray: false,
100
+ allowArrowFunction: true,
101
+ allowCallExpression: true,
102
+ // The true value here is for backward compatibility
103
+ allowLiteral: false,
104
+ allowObject: true,
105
+ },
106
+ ],
107
+ 'no-console': 'error',
108
+ quotes: ['error', 'single', { avoidEscape: true }],
109
+ 'react-hooks/exhaustive-deps': 'error',
110
+ 'react/jsx-curly-brace-presence': [
111
+ 'error',
112
+ {
113
+ children: 'never',
114
+ props: 'never',
115
+ },
116
+ ],
117
+ 'react/jsx-sort-props': [
118
+ 2,
119
+ {
120
+ noSortAlphabetically: false,
121
+ },
122
+ ],
123
+ 'react/react-in-jsx-scope': 'off',
124
+ 'simple-import-sort/imports': 'error',
125
+ 'simple-import-sort/exports': 'error',
126
+ 'sort-keys': 'error',
127
+ },
128
+ parser: '@typescript-eslint/parser',
129
+ parserOptions: {
130
+ ecmaFeatures: {
131
+ jsx: true,
132
+ },
133
+ ecmaVersion: 2021,
134
+ sourceType: 'module',
135
+ warnOnUnsupportedTypeScriptVersion: false,
136
+ },
137
+ settings: {
138
+ react: {
139
+ version: 'detect',
140
+ },
141
+ 'import/parsers': {
142
+ [require.resolve('@typescript-eslint/parser')]: [
143
+ '.ts',
144
+ '.mts',
145
+ '.cts',
146
+ '.tsx',
147
+ '.d.ts',
148
+ ],
149
+ },
150
+ 'import/resolver': {
151
+ [require.resolve('eslint-import-resolver-node')]: {
152
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
153
+ },
154
+ [require.resolve('eslint-import-resolver-typescript')]: {
155
+ alwaysTryTypes: true,
156
+ },
157
+ },
158
+ },
159
+ env: {
160
+ browser: true,
161
+ node: true,
162
+ },
163
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allthings/eslint-config",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "ESlint shareable config for Allthings style",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -17,23 +17,27 @@
17
17
  "poatdeploy": "git push --tags origin HEAD"
18
18
  },
19
19
  "dependencies": {
20
- "@typescript-eslint/eslint-plugin": "^5.45.0",
20
+ "@rushstack/eslint-patch": "^1.2.0",
21
+ "@typescript-eslint/eslint-plugin": "^5.47.1",
22
+ "@typescript-eslint/parser": "^5.47.1",
21
23
  "eslint-config-prettier": "^8.5.0",
24
+ "eslint-import-resolver-node": "^0.3.6",
25
+ "eslint-import-resolver-typescript": "^3.5.2",
22
26
  "eslint-plugin-import": "^2.26.0",
27
+ "eslint-plugin-jsx-a11y": "^6.6.1",
23
28
  "eslint-plugin-n": "^15.5.1",
29
+ "eslint-plugin-prettier": "^4.2.1",
24
30
  "eslint-plugin-react": "^7.31.11",
25
31
  "eslint-plugin-react-hooks": "^4.6.0",
26
32
  "eslint-plugin-simple-import-sort": "^8.0.0",
27
33
  "eslint-plugin-typescript-sort-keys": "^2.1.0"
28
34
  },
29
35
  "peerDependencies": {
30
- "@typescript-eslint/parser": ">=5.23.0",
31
36
  "eslint": ">=8.28.0",
32
37
  "prettier": ">=2.8.0",
33
38
  "typescript": ">=4"
34
39
  },
35
40
  "devDependencies": {
36
- "@typescript-eslint/parser": ">=5.23.0",
37
41
  "eslint": "^8.28.0",
38
42
  "prettier": "2.8.0",
39
43
  "typescript": ">=4"