@thermarthae/eslint-config 5.0.0 → 7.0.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/.yarn/sdks/eslint/lib/types/index.d.ts +32 -0
- package/README.md +5 -11
- package/base.js +34 -12
- package/index.js +4 -17
- package/package.json +28 -34
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const {existsSync} = require(`fs`);
|
|
4
|
+
const {createRequire, register} = require(`module`);
|
|
5
|
+
const {resolve} = require(`path`);
|
|
6
|
+
const {pathToFileURL} = require(`url`);
|
|
7
|
+
|
|
8
|
+
const relPnpApiPath = "../../../../../.pnp.cjs";
|
|
9
|
+
|
|
10
|
+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
11
|
+
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
|
|
12
|
+
const absRequire = createRequire(absPnpApiPath);
|
|
13
|
+
|
|
14
|
+
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
|
|
15
|
+
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
|
|
16
|
+
|
|
17
|
+
if (existsSync(absPnpApiPath)) {
|
|
18
|
+
if (!process.versions.pnp) {
|
|
19
|
+
// Setup the environment to be able to require eslint
|
|
20
|
+
require(absPnpApiPath).setup();
|
|
21
|
+
if (isPnpLoaderEnabled && register) {
|
|
22
|
+
register(pathToFileURL(absPnpLoaderPath));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const wrapWithUserWrapper = existsSync(absUserWrapperPath)
|
|
28
|
+
? exports => absRequire(absUserWrapperPath)(exports)
|
|
29
|
+
: exports => exports;
|
|
30
|
+
|
|
31
|
+
// Defer to the real eslint your application uses
|
|
32
|
+
module.exports = wrapWithUserWrapper(absRequire(`eslint`));
|
package/README.md
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
# @thermarthae/eslint-config
|
|
2
2
|
|
|
3
|
-
Just an
|
|
3
|
+
Just an ESLint config.
|
|
4
4
|
|
|
5
5
|
## ✨ Setup
|
|
6
6
|
|
|
7
7
|
### 1) Install
|
|
8
8
|
|
|
9
|
-
This step assumes that you have already installed
|
|
9
|
+
This step assumes that you have already installed ESLint and Typescript.
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
yarn add -D @thermarthae/eslint-config
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
If you don't need React support:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
yarn add -D @thermarthae/eslint-config @eslint/js typescript-eslint eslint-plugin-simple-import-sort @stylistic/eslint-plugin
|
|
12
|
+
yarn add -D @thermarthae/eslint-config
|
|
19
13
|
```
|
|
20
14
|
|
|
21
15
|
### 2) Configure ESLint
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
An example `eslint.config.js`:
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
**Note**: You may have to set the `tsconfigRootDir` path!
|
|
26
20
|
|
|
27
21
|
```js
|
|
28
22
|
// If you don't need React support:
|
package/base.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import eslint from '@eslint/js';
|
|
2
2
|
import stylistic from '@stylistic/eslint-plugin';
|
|
3
3
|
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
4
|
-
import
|
|
4
|
+
import tsESLint from 'typescript-eslint';
|
|
5
5
|
|
|
6
6
|
const stylisticCustomized = stylistic.configs.customize({
|
|
7
|
-
flat: true,
|
|
8
7
|
indent: 'tab',
|
|
9
8
|
semi: true,
|
|
10
9
|
jsx: false,
|
|
@@ -12,7 +11,7 @@ const stylisticCustomized = stylistic.configs.customize({
|
|
|
12
11
|
quoteProps: 'as-needed',
|
|
13
12
|
});
|
|
14
13
|
|
|
15
|
-
/** @type {
|
|
14
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
16
15
|
const base = [
|
|
17
16
|
//
|
|
18
17
|
// eslint
|
|
@@ -38,12 +37,8 @@ const base = [
|
|
|
38
37
|
//
|
|
39
38
|
// typescript-eslint
|
|
40
39
|
//
|
|
41
|
-
...
|
|
42
|
-
...
|
|
43
|
-
{
|
|
44
|
-
...tsEslint.configs.disableTypeChecked,
|
|
45
|
-
files: ['*.cjs', '*.js'],
|
|
46
|
-
},
|
|
40
|
+
...tsESLint.configs.strictTypeChecked,
|
|
41
|
+
...tsESLint.configs.stylisticTypeChecked,
|
|
47
42
|
{
|
|
48
43
|
languageOptions: {
|
|
49
44
|
parserOptions: {
|
|
@@ -56,20 +51,47 @@ const base = [
|
|
|
56
51
|
default: 'array-simple',
|
|
57
52
|
}],
|
|
58
53
|
'@typescript-eslint/consistent-type-assertions': ['error', {
|
|
59
|
-
assertionStyle: 'as',
|
|
60
54
|
objectLiteralTypeAssertions: 'allow-as-parameter',
|
|
61
55
|
}],
|
|
62
56
|
'@typescript-eslint/consistent-type-definitions': 0,
|
|
63
|
-
'@typescript-eslint/
|
|
57
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
58
|
+
'@typescript-eslint/no-confusing-void-expression': 0,
|
|
64
59
|
'@typescript-eslint/no-empty-function': 0,
|
|
60
|
+
'@typescript-eslint/no-extraneous-class': ['error', {
|
|
61
|
+
allowConstructorOnly: false,
|
|
62
|
+
allowEmpty: false,
|
|
63
|
+
allowStaticOnly: true,
|
|
64
|
+
allowWithDecorator: false,
|
|
65
|
+
}],
|
|
66
|
+
'@typescript-eslint/no-import-type-side-effects': 'error',
|
|
65
67
|
'@typescript-eslint/no-misused-promises': ['error', {
|
|
66
68
|
checksVoidReturn: false,
|
|
67
69
|
}],
|
|
68
|
-
'@typescript-eslint/no-
|
|
70
|
+
'@typescript-eslint/no-non-null-assertion': 0,
|
|
69
71
|
'@typescript-eslint/no-shadow': 'error',
|
|
72
|
+
'@typescript-eslint/no-unused-vars': 0,
|
|
70
73
|
'@typescript-eslint/promise-function-async': 'error',
|
|
74
|
+
'@typescript-eslint/restrict-plus-operands': ['error', {
|
|
75
|
+
allowAny: false,
|
|
76
|
+
allowBoolean: true,
|
|
77
|
+
allowNullish: true,
|
|
78
|
+
allowNumberAndString: true,
|
|
79
|
+
allowRegExp: false,
|
|
80
|
+
}],
|
|
81
|
+
'@typescript-eslint/restrict-template-expressions': ['error', {
|
|
82
|
+
allowAny: false,
|
|
83
|
+
allowBoolean: true,
|
|
84
|
+
allowNever: false,
|
|
85
|
+
allowNullish: true,
|
|
86
|
+
allowNumber: true,
|
|
87
|
+
allowRegExp: false,
|
|
88
|
+
}],
|
|
71
89
|
},
|
|
72
90
|
},
|
|
91
|
+
{
|
|
92
|
+
...tsESLint.configs.disableTypeChecked,
|
|
93
|
+
files: ['*.cjs', '*.js'],
|
|
94
|
+
},
|
|
73
95
|
//
|
|
74
96
|
// stylistic
|
|
75
97
|
//
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import react from 'eslint-plugin-react';
|
|
2
|
-
// @ts-expect-error no types :/
|
|
3
2
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
4
3
|
import stylistic from '@stylistic/eslint-plugin';
|
|
5
4
|
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
@@ -7,7 +6,6 @@ import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
|
7
6
|
import base from './base.js';
|
|
8
7
|
|
|
9
8
|
const stylisticCustomizedWithJSX = stylistic.configs.customize({
|
|
10
|
-
flat: true,
|
|
11
9
|
indent: 'tab',
|
|
12
10
|
semi: true,
|
|
13
11
|
jsx: true,
|
|
@@ -19,17 +17,14 @@ const stylisticCustomizedWithJSX = stylistic.configs.customize({
|
|
|
19
17
|
const jsxStylisticRules = Object.fromEntries(Object.entries(stylisticCustomizedWithJSX.rules ?? {})
|
|
20
18
|
.filter(r => r[0].startsWith('@stylistic/jsx')));
|
|
21
19
|
|
|
22
|
-
/** @type {
|
|
20
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
23
21
|
const main = [
|
|
24
22
|
...base,
|
|
25
23
|
//
|
|
26
24
|
// react
|
|
27
25
|
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// TODO: wait for a types fix
|
|
31
|
-
/** @type {typeof import('typescript-eslint').configs.base} */ (react.configs.flat.recommended),
|
|
32
|
-
/** @type {typeof import('typescript-eslint').configs.base} */ (react.configs.flat['jsx-runtime']),
|
|
26
|
+
react.configs.flat.recommended,
|
|
27
|
+
react.configs.flat['jsx-runtime'],
|
|
33
28
|
{
|
|
34
29
|
settings: {
|
|
35
30
|
react: {
|
|
@@ -56,14 +51,7 @@ const main = [
|
|
|
56
51
|
//
|
|
57
52
|
// react-hooks
|
|
58
53
|
//
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
files: ['**/**/*.{js,ts,jsx,tsx}'],
|
|
62
|
-
plugins: {
|
|
63
|
-
'react-hooks': reactHooks,
|
|
64
|
-
},
|
|
65
|
-
rules: reactHooks.configs.recommended.rules,
|
|
66
|
-
},
|
|
54
|
+
...reactHooks.configs['recommended-latest'],
|
|
67
55
|
//
|
|
68
56
|
// jsx-a11y
|
|
69
57
|
//
|
|
@@ -88,7 +76,6 @@ const main = [
|
|
|
88
76
|
}],
|
|
89
77
|
'@stylistic/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
|
|
90
78
|
'@stylistic/jsx-self-closing-comp': 'error',
|
|
91
|
-
'@stylistic/jsx-props-no-multi-spaces': 'error',
|
|
92
79
|
},
|
|
93
80
|
},
|
|
94
81
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thermarthae/eslint-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"import": "./index.js",
|
|
8
|
+
"default": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"./base": {
|
|
11
|
+
"types": "./base.d.ts",
|
|
12
|
+
"import": "./base.js",
|
|
13
|
+
"default": "./base.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
5
16
|
"description": "Just a personal eslint config",
|
|
6
17
|
"type": "module",
|
|
7
18
|
"license": "MIT",
|
|
@@ -16,44 +27,27 @@
|
|
|
16
27
|
"index.js",
|
|
17
28
|
"index.d.ts"
|
|
18
29
|
],
|
|
19
|
-
"packageManager": "yarn@4.
|
|
30
|
+
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f",
|
|
20
31
|
"scripts": {
|
|
21
32
|
"pnpify": "yarn dlx @yarnpkg/sdks vscode"
|
|
22
33
|
},
|
|
23
34
|
"devDependencies": {
|
|
24
|
-
"@eslint
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"@types/node": "^22.7.8",
|
|
29
|
-
"eslint": "^9.13.0",
|
|
30
|
-
"eslint-plugin-jsx-a11y": "^6.10.1",
|
|
31
|
-
"eslint-plugin-react": "^7.37.1",
|
|
32
|
-
"eslint-plugin-react-hooks": "^5.0.0",
|
|
33
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
34
|
-
"typescript": "^5.6.3",
|
|
35
|
-
"typescript-eslint": "^8.11.0"
|
|
35
|
+
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
36
|
+
"@types/node": "^24.6.2",
|
|
37
|
+
"eslint": "^9.37.0",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"eslint": "^9.13.0",
|
|
41
|
-
"eslint-plugin-jsx-a11y": "^6.10.1",
|
|
42
|
-
"eslint-plugin-react": "^7.37.1",
|
|
43
|
-
"eslint-plugin-react-hooks": "^5.0.0",
|
|
44
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
45
|
-
"typescript": "^5.6.3",
|
|
46
|
-
"typescript-eslint": "^8.11.0"
|
|
41
|
+
"eslint": "^9.37.0",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
47
43
|
},
|
|
48
|
-
"
|
|
49
|
-
"eslint
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"eslint-plugin-react":
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"eslint
|
|
56
|
-
"optional": true
|
|
57
|
-
}
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@eslint/js": "^9.37.0",
|
|
46
|
+
"@stylistic/eslint-plugin": "^5.4.0",
|
|
47
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
48
|
+
"eslint-plugin-react": "^7.37.5",
|
|
49
|
+
"eslint-plugin-react-hooks": "^6.1.1",
|
|
50
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
51
|
+
"typescript-eslint": "^8.45.0"
|
|
58
52
|
}
|
|
59
53
|
}
|