@singlepixellab/eslint-config 2.1.0 → 2.2.1
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 +11 -9
- package/eslint.config.js +5 -1
- package/index.js +1 -0
- package/package.json +9 -3
- package/rules/core.js +2 -2
- package/rules/ignores.js +1 -0
- package/rules/imports.js +42 -3
- package/rules/react.js +7 -5
- package/rules/typescript.js +38 -0
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ The ESLint rules and configs used by Single Pixel Lab.
|
|
|
6
6
|
|
|
7
7
|
- Node.js ≥ 18
|
|
8
8
|
- ESLint ≥ 9
|
|
9
|
+
- TypeScript ≥ 3.3.1
|
|
9
10
|
|
|
10
11
|
## Usage
|
|
11
12
|
|
|
@@ -40,15 +41,16 @@ export default [...styles, ...react];
|
|
|
40
41
|
|
|
41
42
|
Available modules:
|
|
42
43
|
|
|
43
|
-
| Module
|
|
44
|
-
|
|
|
45
|
-
| Core
|
|
46
|
-
| Ignore
|
|
47
|
-
| Import
|
|
48
|
-
| JSDoc
|
|
49
|
-
| Prettier
|
|
50
|
-
| React
|
|
51
|
-
| Style
|
|
44
|
+
| Module | Import | Description |
|
|
45
|
+
| ---------- | ------------------------------------------ | ------------------------------ |
|
|
46
|
+
| Core | `@singlepixellab/eslint-config/core` | Base ESLint rules |
|
|
47
|
+
| Ignore | `@singlepixellab/eslint-config/ignores` | Default ignore patterns |
|
|
48
|
+
| Import | `@singlepixellab/eslint-config/imports` | Import ordering and validation |
|
|
49
|
+
| JSDoc | `@singlepixellab/eslint-config/jsdoc` | JSDoc linting |
|
|
50
|
+
| Prettier | `@singlepixellab/eslint-config/prettier` | Prettier integration |
|
|
51
|
+
| React | `@singlepixellab/eslint-config/react` | React and Hooks rules |
|
|
52
|
+
| Style | `@singlepixellab/eslint-config/styles` | Stylistic rules |
|
|
53
|
+
| TypeScript | `@singlepixellab/eslint-config/typescript` | TypeScript linting |
|
|
52
54
|
|
|
53
55
|
### Named exports
|
|
54
56
|
|
package/eslint.config.js
CHANGED
|
@@ -5,12 +5,15 @@ import react from "./rules/react.js";
|
|
|
5
5
|
import prettier from "./rules/prettier.js";
|
|
6
6
|
import jsdoc from "./rules/jsdoc.js";
|
|
7
7
|
import styles from "./rules/styles.js";
|
|
8
|
+
import typescript from "./rules/typescript.js";
|
|
8
9
|
|
|
9
10
|
/** @type {import('eslint').Linter.Config[]} */
|
|
10
11
|
export default [
|
|
11
12
|
// Global ignores should always be first
|
|
12
13
|
...ignores,
|
|
13
14
|
|
|
15
|
+
...core,
|
|
16
|
+
|
|
14
17
|
// eslint-plugin-import
|
|
15
18
|
...imports,
|
|
16
19
|
|
|
@@ -20,7 +23,8 @@ export default [
|
|
|
20
23
|
// eslint-plugin-react, eslint-plugin-react-hooks etc
|
|
21
24
|
...react,
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
// @typescript-eslint
|
|
27
|
+
...typescript,
|
|
24
28
|
|
|
25
29
|
// styles: @stylistic/eslint-plugin
|
|
26
30
|
...styles,
|
package/index.js
CHANGED
|
@@ -9,3 +9,4 @@ export { default as jsdocConfig } from "./rules/jsdoc.js";
|
|
|
9
9
|
export { default as prettierConfig } from "./rules/prettier.js";
|
|
10
10
|
export { default as reactConfig } from "./rules/react.js";
|
|
11
11
|
export { default as stylesConfig } from "./rules/styles.js";
|
|
12
|
+
export { default as typescriptConfig } from "./rules/typescript.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singlepixellab/eslint-config",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "The ESLint rules and configs used by Single Pixel Lab",
|
|
5
5
|
"author": "Single Pixel Lab",
|
|
6
6
|
"keywords": [
|
|
@@ -50,13 +50,17 @@
|
|
|
50
50
|
},
|
|
51
51
|
"./styles": {
|
|
52
52
|
"import": "./rules/styles.js"
|
|
53
|
+
},
|
|
54
|
+
"./typescript": {
|
|
55
|
+
"import": "./rules/typescript.js"
|
|
53
56
|
}
|
|
54
57
|
},
|
|
55
58
|
"engines": {
|
|
56
59
|
"node": ">=18"
|
|
57
60
|
},
|
|
58
61
|
"peerDependencies": {
|
|
59
|
-
"eslint": ">= 9"
|
|
62
|
+
"eslint": ">= 9",
|
|
63
|
+
"typescript": ">=3.3.1"
|
|
60
64
|
},
|
|
61
65
|
"scripts": {
|
|
62
66
|
"format": "prettier --cache --write .",
|
|
@@ -73,12 +77,14 @@
|
|
|
73
77
|
"@eslint/js": "^9.39.4",
|
|
74
78
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
75
79
|
"eslint-config-prettier": "^10.1.8",
|
|
80
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
76
81
|
"eslint-plugin-import": "^2.32.0",
|
|
77
82
|
"eslint-plugin-jsdoc": "^62.7.1",
|
|
78
83
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
79
84
|
"eslint-plugin-prettier": "^5.5.5",
|
|
80
85
|
"eslint-plugin-react": "^7.37.5",
|
|
81
86
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
82
|
-
"globals": "^17.4.0"
|
|
87
|
+
"globals": "^17.4.0",
|
|
88
|
+
"typescript-eslint": "^8.58.2"
|
|
83
89
|
}
|
|
84
90
|
}
|
package/rules/core.js
CHANGED
package/rules/ignores.js
CHANGED
package/rules/imports.js
CHANGED
|
@@ -5,7 +5,20 @@ export default [
|
|
|
5
5
|
importPlugin.flatConfigs.recommended,
|
|
6
6
|
{
|
|
7
7
|
name: "spl/imports",
|
|
8
|
-
files: ["**/*.{js,mjs,cjs}"],
|
|
8
|
+
files: ["**/*.{js,mjs,cjs,ts,tsx,mts,cts}"],
|
|
9
|
+
settings: {
|
|
10
|
+
"import/parsers": {
|
|
11
|
+
"@typescript-eslint/parser": [".ts", ".mts", ".cts", ".tsx", ".d.ts"],
|
|
12
|
+
},
|
|
13
|
+
"import/resolver": {
|
|
14
|
+
node: {
|
|
15
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
|
|
16
|
+
},
|
|
17
|
+
typescript: {
|
|
18
|
+
alwaysTryTypes: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
9
22
|
rules: {
|
|
10
23
|
// Ensures imports point to a file/module that exists, prevents broken
|
|
11
24
|
// imports
|
|
@@ -55,8 +68,34 @@ export default [
|
|
|
55
68
|
"import/order": [
|
|
56
69
|
"error",
|
|
57
70
|
{
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
"alphabetize": {
|
|
72
|
+
order: "asc",
|
|
73
|
+
caseInsensitive: true,
|
|
74
|
+
},
|
|
75
|
+
"distinctGroup": false,
|
|
76
|
+
"newlines-between": "always",
|
|
77
|
+
"named": {
|
|
78
|
+
enabled: true,
|
|
79
|
+
types: "types-last",
|
|
80
|
+
},
|
|
81
|
+
"sortTypesGroup": true,
|
|
82
|
+
"pathGroups": [
|
|
83
|
+
{
|
|
84
|
+
pattern: "~*/**",
|
|
85
|
+
group: "external",
|
|
86
|
+
position: "after",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
"groups": [
|
|
90
|
+
[
|
|
91
|
+
"builtin",
|
|
92
|
+
"external",
|
|
93
|
+
"internal",
|
|
94
|
+
"parent",
|
|
95
|
+
"sibling",
|
|
96
|
+
"index",
|
|
97
|
+
"type",
|
|
98
|
+
],
|
|
60
99
|
],
|
|
61
100
|
},
|
|
62
101
|
],
|
package/rules/react.js
CHANGED
|
@@ -6,7 +6,7 @@ import reactHooks from "eslint-plugin-react-hooks";
|
|
|
6
6
|
export default [
|
|
7
7
|
{
|
|
8
8
|
name: "spl/react",
|
|
9
|
-
files: ["**/*.js"],
|
|
9
|
+
files: ["**/*.{js,tsx}"],
|
|
10
10
|
settings: {
|
|
11
11
|
react: {
|
|
12
12
|
version: "detect",
|
|
@@ -64,9 +64,11 @@ export default [
|
|
|
64
64
|
// Enforce or disallow spaces around equal sign
|
|
65
65
|
"react/jsx-equals-spacing": "off",
|
|
66
66
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// Restrict file extensions that may contain JSX
|
|
68
|
+
"react/jsx-filename-extension": [
|
|
69
|
+
"error",
|
|
70
|
+
{ extensions: [".js", ".tsx"] },
|
|
71
|
+
],
|
|
70
72
|
|
|
71
73
|
// Enforce shorthand or standard form for React fragments
|
|
72
74
|
"react/jsx-fragments": ["warn", "syntax"],
|
|
@@ -169,7 +171,7 @@ export default [
|
|
|
169
171
|
"error",
|
|
170
172
|
{
|
|
171
173
|
"elements": ["img", "object", "area", 'input[type="image"]'],
|
|
172
|
-
"img": [],
|
|
174
|
+
"img": ["Image"],
|
|
173
175
|
"object": [],
|
|
174
176
|
"area": [],
|
|
175
177
|
'input[type="image"]': [],
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import tsEslint from "typescript-eslint";
|
|
2
|
+
|
|
3
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
4
|
+
export default [
|
|
5
|
+
...tsEslint.configs.recommended,
|
|
6
|
+
...tsEslint.configs.stylistic,
|
|
7
|
+
{
|
|
8
|
+
name: "spl/typescript",
|
|
9
|
+
files: ["**/*.{ts,tsx,mts,cts}"],
|
|
10
|
+
plugins: {
|
|
11
|
+
"@typescript-eslint": tsEslint.plugin,
|
|
12
|
+
},
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parser: tsEslint.parser,
|
|
15
|
+
parserOptions: {
|
|
16
|
+
ecmaFeatures: {
|
|
17
|
+
jsx: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
// Ensure that all explicitly declared properties are actually used
|
|
23
|
+
"no-unused-vars": "off",
|
|
24
|
+
"@typescript-eslint/no-unused-vars": [
|
|
25
|
+
"error",
|
|
26
|
+
{
|
|
27
|
+
args: "all",
|
|
28
|
+
argsIgnorePattern: "^_",
|
|
29
|
+
caughtErrors: "all",
|
|
30
|
+
caughtErrorsIgnorePattern: "^_",
|
|
31
|
+
destructuredArrayIgnorePattern: "^_",
|
|
32
|
+
varsIgnorePattern: "^_",
|
|
33
|
+
ignoreRestSiblings: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
];
|