@peerigon/configs 4.1.0 → 4.3.0-beta.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/CHANGELOG.md +14 -0
- package/{types → dist}/eslint/lib/glob-patterns.d.ts +0 -1
- package/dist/eslint/lib/glob-patterns.js +11 -0
- package/{types → dist}/eslint/lib/rule-options.d.ts +0 -1
- package/dist/eslint/lib/rule-options.js +127 -0
- package/{types → dist}/eslint/presets/javascript-browser.d.ts +0 -1
- package/{eslint → dist/eslint}/presets/javascript-browser.js +4 -6
- package/{types → dist}/eslint/presets/javascript-node.d.ts +0 -1
- package/{eslint → dist/eslint}/presets/javascript-node.js +4 -6
- package/{types → dist}/eslint/presets/javascript.d.ts +0 -1
- package/{eslint → dist/eslint}/presets/javascript.js +0 -2
- package/{types → dist}/eslint/presets/typescript-node.d.ts +0 -1
- package/{eslint → dist/eslint}/presets/typescript-node.js +5 -7
- package/{types → dist}/eslint/presets/typescript-react.d.ts +0 -1
- package/{eslint → dist/eslint}/presets/typescript-react.js +6 -8
- package/{types → dist}/eslint/presets/typescript.d.ts +0 -1
- package/{eslint → dist/eslint}/presets/typescript.js +4 -6
- package/{types → dist}/eslint/rules/base.d.ts +0 -1
- package/{eslint → dist/eslint}/rules/base.js +5 -8
- package/{types → dist}/eslint/rules/browser.d.ts +0 -1
- package/{eslint → dist/eslint}/rules/browser.js +4 -6
- package/{types → dist}/eslint/rules/javascript.d.ts +0 -1
- package/dist/eslint/rules/javascript.js +153 -0
- package/{types → dist}/eslint/rules/node.d.ts +0 -1
- package/{eslint → dist/eslint}/rules/node.js +4 -6
- package/{types → dist}/eslint/rules/react.d.ts +0 -1
- package/dist/eslint/rules/react.js +166 -0
- package/{types → dist}/eslint/rules/typescript.d.ts +0 -1
- package/dist/eslint/rules/typescript.js +195 -0
- package/{types → dist}/eslint/styles/jsx-no-literals.d.ts +0 -1
- package/dist/eslint/styles/jsx-no-literals.js +29 -0
- package/{types → dist}/eslint/styles/no-default-export.d.ts +0 -1
- package/dist/eslint/styles/no-default-export.js +18 -0
- package/{types → dist}/eslint/styles/no-null.d.ts +0 -1
- package/{eslint → dist/eslint}/styles/no-null.js +4 -5
- package/{types → dist}/eslint/styles/prefer-array-shorthand.d.ts +0 -1
- package/dist/eslint/styles/prefer-array-shorthand.js +14 -0
- package/{types → dist}/eslint/styles/prefer-interface.d.ts +0 -1
- package/dist/eslint/styles/prefer-interface.js +9 -0
- package/dist/prettier/base.d.ts +7 -0
- package/dist/prettier/base.js +75 -0
- package/{types → dist}/semantic-release/base.d.ts +0 -1
- package/dist/semantic-release/base.js +40 -0
- package/{types → dist}/semantic-release/cross-publish.d.ts +0 -1
- package/dist/semantic-release/cross-publish.js +31 -0
- package/dist/typescript/base.json +41 -0
- package/dist/typescript/configs.d.ts +1 -0
- package/dist/typescript/configs.js +4 -0
- package/dist/typescript/js-lib.json +9 -0
- package/dist/typescript/lib.json +11 -0
- package/package.json +22 -73
- package/eslint/README.md +0 -119
- package/eslint/lib/glob-patterns.js +0 -11
- package/eslint/lib/rule-options.js +0 -130
- package/eslint/presets/javascript.test/eslint.config.js +0 -1
- package/eslint/presets/javascript.test/main.js +0 -62
- package/eslint/presets/javascript.test/other.js +0 -2
- package/eslint/presets/typescript-react.test/App.tsx +0 -47
- package/eslint/presets/typescript-react.test/Other.tsx +0 -5
- package/eslint/presets/typescript-react.test/eslint.config.js +0 -1
- package/eslint/presets/typescript-react.test/tsconfig.json +0 -7
- package/eslint/presets/typescript.test/eslint.config.js +0 -1
- package/eslint/presets/typescript.test/main.ts +0 -42
- package/eslint/presets/typescript.test/message.ts +0 -3
- package/eslint/presets/typescript.test/test.json +0 -1
- package/eslint/presets/typescript.test/tsconfig.json +0 -4
- package/eslint/presets/typescript.test/types.d.ts +0 -11
- package/eslint/rules/javascript.js +0 -157
- package/eslint/rules/react.js +0 -169
- package/eslint/rules/typescript.js +0 -206
- package/eslint/styles/jsx-no-literals.js +0 -31
- package/eslint/styles/jsx-no-literals.test/eslint.config.js +0 -4
- package/eslint/styles/jsx-no-literals.test/main.tsx +0 -4
- package/eslint/styles/jsx-no-literals.test/tsconfig.json +0 -7
- package/eslint/styles/no-default-export.js +0 -20
- package/eslint/styles/no-default-export.test/eslint.config.js +0 -4
- package/eslint/styles/no-default-export.test/main.ts +0 -2
- package/eslint/styles/no-default-export.test/tsconfig.json +0 -4
- package/eslint/styles/no-default-export.test/vitest.config.ts +0 -1
- package/eslint/styles/no-null.test/eslint.config.js +0 -4
- package/eslint/styles/no-null.test/main.ts +0 -2
- package/eslint/styles/no-null.test/tsconfig.json +0 -4
- package/eslint/styles/prefer-array-shorthand.js +0 -15
- package/eslint/styles/prefer-array-shorthand.test/eslint.config.js +0 -4
- package/eslint/styles/prefer-array-shorthand.test/main.ts +0 -4
- package/eslint/styles/prefer-array-shorthand.test/tsconfig.json +0 -4
- package/eslint/styles/prefer-interface.js +0 -10
- package/eslint/styles/prefer-interface.test/eslint.config.js +0 -4
- package/eslint/styles/prefer-interface.test/main.ts +0 -8
- package/eslint/styles/prefer-interface.test/tsconfig.json +0 -4
- package/eslint/types.d.ts +0 -50
- package/prettier/README.md +0 -35
- package/prettier/base.js +0 -35
- package/prettier/css.test/styles.css +0 -9
- package/semantic-release/README.md +0 -81
- package/semantic-release/base.js +0 -41
- package/semantic-release/cross-publish.js +0 -41
- package/types/eslint/lib/glob-patterns.d.ts.map +0 -1
- package/types/eslint/lib/rule-options.d.ts.map +0 -1
- package/types/eslint/presets/javascript-browser.d.ts.map +0 -1
- package/types/eslint/presets/javascript-node.d.ts.map +0 -1
- package/types/eslint/presets/javascript.d.ts.map +0 -1
- package/types/eslint/presets/javascript.test/eslint.config.d.ts +0 -2
- package/types/eslint/presets/javascript.test/eslint.config.d.ts.map +0 -1
- package/types/eslint/presets/javascript.test/main.d.ts +0 -2
- package/types/eslint/presets/javascript.test/main.d.ts.map +0 -1
- package/types/eslint/presets/javascript.test/other.d.ts +0 -3
- package/types/eslint/presets/javascript.test/other.d.ts.map +0 -1
- package/types/eslint/presets/typescript-node.d.ts.map +0 -1
- package/types/eslint/presets/typescript-react.d.ts.map +0 -1
- package/types/eslint/presets/typescript.d.ts.map +0 -1
- package/types/eslint/rules/base.d.ts.map +0 -1
- package/types/eslint/rules/browser.d.ts.map +0 -1
- package/types/eslint/rules/javascript.d.ts.map +0 -1
- package/types/eslint/rules/node.d.ts.map +0 -1
- package/types/eslint/rules/react.d.ts.map +0 -1
- package/types/eslint/rules/typescript.d.ts.map +0 -1
- package/types/eslint/styles/jsx-no-literals.d.ts.map +0 -1
- package/types/eslint/styles/no-default-export.d.ts.map +0 -1
- package/types/eslint/styles/no-default-export.test/eslint.config.d.ts +0 -3
- package/types/eslint/styles/no-default-export.test/eslint.config.d.ts.map +0 -1
- package/types/eslint/styles/no-default-export.test/main.d.ts +0 -3
- package/types/eslint/styles/no-default-export.test/main.d.ts.map +0 -1
- package/types/eslint/styles/no-default-export.test/vitest.config.d.ts +0 -3
- package/types/eslint/styles/no-default-export.test/vitest.config.d.ts.map +0 -1
- package/types/eslint/styles/no-null.d.ts.map +0 -1
- package/types/eslint/styles/no-null.test/eslint.config.d.ts +0 -3
- package/types/eslint/styles/no-null.test/eslint.config.d.ts.map +0 -1
- package/types/eslint/styles/no-null.test/main.d.ts +0 -2
- package/types/eslint/styles/no-null.test/main.d.ts.map +0 -1
- package/types/eslint/styles/prefer-array-shorthand.d.ts.map +0 -1
- package/types/eslint/styles/prefer-array-shorthand.test/eslint.config.d.ts +0 -3
- package/types/eslint/styles/prefer-array-shorthand.test/eslint.config.d.ts.map +0 -1
- package/types/eslint/styles/prefer-array-shorthand.test/main.d.ts +0 -3
- package/types/eslint/styles/prefer-array-shorthand.test/main.d.ts.map +0 -1
- package/types/eslint/styles/prefer-interface.d.ts.map +0 -1
- package/types/eslint/styles/prefer-interface.test/eslint.config.d.ts +0 -3
- package/types/eslint/styles/prefer-interface.test/eslint.config.d.ts.map +0 -1
- package/types/eslint/styles/prefer-interface.test/main.d.ts +0 -7
- package/types/eslint/styles/prefer-interface.test/main.d.ts.map +0 -1
- package/types/prettier/base.d.ts +0 -4
- package/types/prettier/base.d.ts.map +0 -1
- package/types/semantic-release/base.d.ts.map +0 -1
- package/types/semantic-release/cross-publish.d.ts.map +0 -1
- package/typescript/README.md +0 -63
- package/typescript/base.json +0 -44
- package/typescript/js-lib.json +0 -8
- package/typescript/lib.json +0 -11
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { config as baseConfig } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* @param {{ github: boolean; jsr: boolean }} options?
|
|
4
|
+
* @returns {import("semantic-release").Options}
|
|
5
|
+
*/
|
|
6
|
+
export const config = ({ github = false, jsr = false } = { github: true, jsr: true }) => {
|
|
7
|
+
/** @type {import("semantic-release").PluginSpec[]} */
|
|
8
|
+
const plugins = [];
|
|
9
|
+
if (baseConfig.plugins) {
|
|
10
|
+
plugins.push(...baseConfig.plugins);
|
|
11
|
+
}
|
|
12
|
+
if (github) {
|
|
13
|
+
plugins.push([
|
|
14
|
+
"@semantic-release/exec",
|
|
15
|
+
{
|
|
16
|
+
verifyConditionsCmd: 'echo "registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=${process.env.GITHUB_TOKEN}" > /tmp/github.npmrc && npm whoami --userconfig /tmp/github.npmrc',
|
|
17
|
+
publishCmd: "npm publish --userconfig /tmp/github.npmrc --tag ${nextRelease.channel} --no-git-tag-version",
|
|
18
|
+
successCmd: "rm /tmp/github.npmrc",
|
|
19
|
+
failCmd: "rm /tmp/github.npmrc",
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
if (jsr) {
|
|
24
|
+
plugins.push("@sebbo2002/semantic-release-jsr");
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
...baseConfig,
|
|
28
|
+
plugins,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default config();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Inspired by https://www.totaltypescript.com/tsconfig-cheat-sheet
|
|
3
|
+
// and https://2ality.com/2025/01/tsconfig-json.html
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
// == Target and module settings ==
|
|
6
|
+
// Deliberately not using ESNext/NodeNext here to avoid breaking changes just by updating TypeScript.
|
|
7
|
+
"target": "es2022",
|
|
8
|
+
"module": "Preserve",
|
|
9
|
+
"moduleDetection": "force",
|
|
10
|
+
"lib": ["es2022"],
|
|
11
|
+
// == Strictness settings ==
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitOverride": true,
|
|
14
|
+
// Warns about functions with implicit returns where other code paths return a value.
|
|
15
|
+
// This option is basically the same as ESLint's `consistent-return` rule.
|
|
16
|
+
"noImplicitReturns": true,
|
|
17
|
+
"noUncheckedIndexedAccess": true,
|
|
18
|
+
"noUncheckedSideEffectImports": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
// We decided to turn off `exactOptionalPropertyTypes` because it's too strict
|
|
21
|
+
// by complaining about too much unproblematic code. We may revisit this decision later.
|
|
22
|
+
"exactOptionalPropertyTypes": false,
|
|
23
|
+
// == Module resolution settings ==
|
|
24
|
+
"resolveJsonModule": true,
|
|
25
|
+
"rewriteRelativeImportExtensions": true,
|
|
26
|
+
"allowImportingTsExtensions": true,
|
|
27
|
+
// == Other settings ==
|
|
28
|
+
"allowJs": true,
|
|
29
|
+
"checkJs": true,
|
|
30
|
+
"forceConsistentCasingInFileNames": true,
|
|
31
|
+
// Using noEmit true here because you should have a separate build config anyway
|
|
32
|
+
"noEmit": true,
|
|
33
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
// Not setting skipLibCheck: true for now because it can hide type conflicts in dependencies
|
|
35
|
+
// You can override this in your app if you can't fix it with your package manager.
|
|
36
|
+
"skipLibCheck": false,
|
|
37
|
+
"verbatimModuleSyntax": true
|
|
38
|
+
},
|
|
39
|
+
"exclude": ["${configDir}/dist"],
|
|
40
|
+
"$schema": "https://json.schemastore.org/tsconfig"
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerigon/configs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0-beta.1",
|
|
4
4
|
"description": "Configs for ESLint, Prettier, TypeScript & friends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -21,79 +21,26 @@
|
|
|
21
21
|
"author": "Peerigon GmbH <hello@peerigon.com>",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
|
-
"./eslint/presets/javascript-browser":
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"./eslint/presets/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"./eslint/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"./
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"./
|
|
41
|
-
"types": "./types/eslint/presets/typescript-react.d.ts",
|
|
42
|
-
"default": "./eslint/presets/typescript-react.js"
|
|
43
|
-
},
|
|
44
|
-
"./eslint/presets/typescript": {
|
|
45
|
-
"types": "./types/eslint/presets/typescript.d.ts",
|
|
46
|
-
"default": "./eslint/presets/typescript.js"
|
|
47
|
-
},
|
|
48
|
-
"./eslint/styles/jsx-no-literals": {
|
|
49
|
-
"types": "./types/eslint/styles/jsx-no-literals.d.ts",
|
|
50
|
-
"default": "./eslint/styles/jsx-no-literals.js"
|
|
51
|
-
},
|
|
52
|
-
"./eslint/styles/no-default-export": {
|
|
53
|
-
"types": "./types/eslint/styles/no-default-export.d.ts",
|
|
54
|
-
"default": "./eslint/styles/no-default-export.js"
|
|
55
|
-
},
|
|
56
|
-
"./eslint/styles/no-null": {
|
|
57
|
-
"types": "./types/eslint/styles/no-null.d.ts",
|
|
58
|
-
"default": "./eslint/styles/no-null.js"
|
|
59
|
-
},
|
|
60
|
-
"./eslint/styles/prefer-array-shorthand": {
|
|
61
|
-
"types": "./types/eslint/styles/prefer-array-shorthand.d.ts",
|
|
62
|
-
"default": "./eslint/styles/prefer-array-shorthand.js"
|
|
63
|
-
},
|
|
64
|
-
"./eslint/styles/prefer-interface": {
|
|
65
|
-
"types": "./types/eslint/styles/prefer-interface.d.ts",
|
|
66
|
-
"default": "./eslint/styles/prefer-interface.js"
|
|
67
|
-
},
|
|
68
|
-
"./prettier": {
|
|
69
|
-
"types": "./types/prettier/base.d.ts",
|
|
70
|
-
"default": "./prettier/base.js"
|
|
71
|
-
},
|
|
72
|
-
"./semantic-release": {
|
|
73
|
-
"types": "./types/semantic-release/base.d.ts",
|
|
74
|
-
"default": "./semantic-release/base.js"
|
|
75
|
-
},
|
|
76
|
-
"./semantic-release/cross-publish": {
|
|
77
|
-
"types": "./types/semantic-release/cross-publish.d.ts",
|
|
78
|
-
"default": "./semantic-release/cross-publish.js"
|
|
79
|
-
},
|
|
80
|
-
"./typescript": {
|
|
81
|
-
"default": "./typescript/base.json"
|
|
82
|
-
},
|
|
83
|
-
"./typescript/lib": {
|
|
84
|
-
"default": "./typescript/lib.json"
|
|
85
|
-
},
|
|
86
|
-
"./typescript/js-lib": {
|
|
87
|
-
"default": "./typescript/js-lib.json"
|
|
88
|
-
}
|
|
24
|
+
"./eslint/presets/javascript-browser": "./dist/eslint/presets/javascript-browser.js",
|
|
25
|
+
"./eslint/presets/javascript-node": "./dist/eslint/presets/javascript-node.js",
|
|
26
|
+
"./eslint/presets/javascript": "./dist/eslint/presets/javascript.js",
|
|
27
|
+
"./eslint/presets/typescript-node": "./dist/eslint/presets/typescript-node.js",
|
|
28
|
+
"./eslint/presets/typescript-react": "./dist/eslint/presets/typescript-react.js",
|
|
29
|
+
"./eslint/presets/typescript": "./dist/eslint/presets/typescript.js",
|
|
30
|
+
"./eslint/styles/jsx-no-literals": "./dist/eslint/styles/jsx-no-literals.js",
|
|
31
|
+
"./eslint/styles/no-default-export": "./dist/eslint/styles/no-default-export.js",
|
|
32
|
+
"./eslint/styles/no-null": "./dist/eslint/styles/no-null.js",
|
|
33
|
+
"./eslint/styles/prefer-array-shorthand": "./dist/eslint/styles/prefer-array-shorthand.js",
|
|
34
|
+
"./eslint/styles/prefer-interface": "./dist/eslint/styles/prefer-interface.js",
|
|
35
|
+
"./prettier": "./dist/prettier/base.js",
|
|
36
|
+
"./semantic-release": "./dist/semantic-release/base.js",
|
|
37
|
+
"./semantic-release/cross-publish": "./dist/semantic-release/cross-publish.js",
|
|
38
|
+
"./typescript": "./dist/typescript/base.json",
|
|
39
|
+
"./typescript/lib": "./dist/typescript/lib.json",
|
|
40
|
+
"./typescript/js-lib": "./dist/typescript/js-lib.json"
|
|
89
41
|
},
|
|
90
42
|
"files": [
|
|
91
|
-
"
|
|
92
|
-
"eslint",
|
|
93
|
-
"prettier",
|
|
94
|
-
"semantic-release",
|
|
95
|
-
"types",
|
|
96
|
-
"typescript",
|
|
43
|
+
"dist",
|
|
97
44
|
"CHANGELOG.md",
|
|
98
45
|
"README.md"
|
|
99
46
|
],
|
|
@@ -110,7 +57,8 @@
|
|
|
110
57
|
"test:types": "tsc --noEmit",
|
|
111
58
|
"test:prettier": "prettier --check .",
|
|
112
59
|
"build": "run-s build:*",
|
|
113
|
-
"build:
|
|
60
|
+
"build:clear": "rimraf dist",
|
|
61
|
+
"build:tsc": "tsc",
|
|
114
62
|
"prepublishOnly": "npm run build",
|
|
115
63
|
"prepare": "husky",
|
|
116
64
|
"release": "semantic-release"
|
|
@@ -152,6 +100,7 @@
|
|
|
152
100
|
"pin-github-action": "^2.1.1",
|
|
153
101
|
"prettier": "^3.5.3",
|
|
154
102
|
"react": "^19.0.0",
|
|
103
|
+
"rimraf": "^6.0.1",
|
|
155
104
|
"semantic-release": "^24.2.3",
|
|
156
105
|
"typescript": "^5.8.2"
|
|
157
106
|
},
|
package/eslint/README.md
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# [ESLint](https://eslint.org/) config
|
|
2
|
-
|
|
3
|
-
## Installation
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm install eslint @peerigon/configs --save-dev
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Then create a `eslint.config.js` next to your `package.json`:
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
// We have a couple of presets for popular setups, such as typescript-react or typescript-node
|
|
13
|
-
// See "Presets"
|
|
14
|
-
import typescriptNodePreset from "@peerigon/configs/eslint/presets/typescript-node";
|
|
15
|
-
// You can also choose from a bunch of optional coding styles
|
|
16
|
-
// See "Styles"
|
|
17
|
-
import stylesNoDefaultExport from "@peerigon/configs/eslint/styles/no-default-export";
|
|
18
|
-
|
|
19
|
-
export default [
|
|
20
|
-
...typescriptNodePreset,
|
|
21
|
-
// The idiomatic way to disable rules in certain directories in ESLint>=9.x is
|
|
22
|
-
// to map() over them and add `ignores` to the rule objects
|
|
23
|
-
...stylesNoDefaultExport.map((config) => ({
|
|
24
|
-
...config,
|
|
25
|
-
ignores: [...(config.ignores ?? []), "src/some/folder/*.ts"],
|
|
26
|
-
})),
|
|
27
|
-
];
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Recommended configuration in your `package.json` (using [`npm-run-all2`](https://www.npmjs.com/package/npm-run-all2)):
|
|
31
|
-
|
|
32
|
-
```json
|
|
33
|
-
{
|
|
34
|
-
"type": "module",
|
|
35
|
-
"scripts": {
|
|
36
|
-
"test": "run-p test:*",
|
|
37
|
-
"test:lint": "eslint --max-warnings 0 --cache ."
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Presets
|
|
43
|
-
|
|
44
|
-
Presets bundle all relevant rules into one `import`. They can be imported as `@peerigon/configs/eslint/presets/<preset-name>`. They **should not** be combined with each other.
|
|
45
|
-
|
|
46
|
-
- `typescript-react`: Rules for React projects written in TypeScript
|
|
47
|
-
- `typescript-node`: Rules for TypeScript apps that are supposed to run in Node.js
|
|
48
|
-
- `typescript`: Rules for all other TypeScript projects
|
|
49
|
-
- `javascript-browser`: Rules for JavaScript apps running in a browser (e.g. in combination with [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html))
|
|
50
|
-
- `javascript-node`: Rules for JavaScript apps running in Node.js
|
|
51
|
-
- `javascript`: Rules for all other JavaScript projects
|
|
52
|
-
|
|
53
|
-
## Styles
|
|
54
|
-
|
|
55
|
-
We acknowledge that there are certain rules where there are no actual pros and cons or where there is no clear winner. You just have to decide for one style and stick with it. We also know that some rules make sense in one project, but don't make sense in another project. Pick these rules if they make sense for you in your project. They can be imported as `@peerigon/configs/eslint/styles/<style-name>`.
|
|
56
|
-
|
|
57
|
-
### `no-default-export`
|
|
58
|
-
|
|
59
|
-
Forbids usage of `export default`. When using default exports, it becomes harder to name classes or functions consistently throughout the codebase since every module can pick its own name for the imported thing. Nicholas C. Zakas, the creator of ESLint, wrote [an article with more compelling arguments why he stopped using `export default`](https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/).
|
|
60
|
-
|
|
61
|
-
You may want to disable this rule in situations where a default export is required, for instance when using [React's `lazy()`](https://react.dev/reference/react/lazy).
|
|
62
|
-
|
|
63
|
-
### `no-null`
|
|
64
|
-
|
|
65
|
-
Forbids the usage of `null`. In a codebase it's often better to use a single non-value to represent _the absence of a value_. With the rise of default parameters and destructuring defaults, JavaScript developed a clear tendency towards `undefined`. [This issue](https://github.com/peerigon/eslint-config-peerigon/issues/71) summarizes the arguments (and trade-offs) of **null vs. undefined**.
|
|
66
|
-
|
|
67
|
-
**👉 Hint:** If you use this rule, you will probably still need a single `null` value which you can refer to whenever you need to use `null` because of third-party code:
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
// eslint-disable-next-line no-null/no-null
|
|
71
|
-
export const NULL = null;
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### `prefer-interface`
|
|
75
|
-
|
|
76
|
-
Prefer TypeScript's `interface` over `type`:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
interface SomeObject {
|
|
80
|
-
someProp: boolean;
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
instead of
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
type SomeObject = {
|
|
88
|
-
someProp: boolean;
|
|
89
|
-
};
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### `prefer-array-shorthand`
|
|
93
|
-
|
|
94
|
-
Enforces TypeScript arrays to use the shorthand array-style instead of the generic style:
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
const foo: string[] = [];
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
instead of
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
const foo: Array<string> = [];
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### `jsx-no-literals`
|
|
107
|
-
|
|
108
|
-
Use this style if you're using i18n. It prevents people from putting raw strings in components.
|
|
109
|
-
It disallows this:
|
|
110
|
-
|
|
111
|
-
```jsx
|
|
112
|
-
const Hello = <div>test</div>;
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
As an escape hatch, this is still allowed:
|
|
116
|
-
|
|
117
|
-
```jsx
|
|
118
|
-
const Hello = <div>{"test"}</div>;
|
|
119
|
-
```
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const globPatterns = {
|
|
2
|
-
javascript: ["**/*.{js,mjs,cjs}"],
|
|
3
|
-
typescript: ["**/*.{ts,cts,mts}"],
|
|
4
|
-
typescriptAmbient: ["**/*.d.ts"],
|
|
5
|
-
jsx: ["**/*.jsx"],
|
|
6
|
-
typescriptJsx: ["**/*.tsx"],
|
|
7
|
-
tests: [
|
|
8
|
-
"**/*.{test,spec,stories}.{js,mjs,cjs,ts,cts,mts,jsx,tsx}",
|
|
9
|
-
"**/test{s,}/**/*.{js,mjs,cjs,ts,cts,mts,jsx,tsx}",
|
|
10
|
-
],
|
|
11
|
-
};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
const camelcase = {
|
|
2
|
-
allow: ["^UNSAFE_"], // Allows React UNSAFE_ methods
|
|
3
|
-
ignoreDestructuring: false,
|
|
4
|
-
properties: "always",
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const ruleOptions = {
|
|
8
|
-
["camelcase"]: camelcase,
|
|
9
|
-
["max-lines"]: {
|
|
10
|
-
max: 700,
|
|
11
|
-
skipBlankLines: true,
|
|
12
|
-
skipComments: true,
|
|
13
|
-
},
|
|
14
|
-
["no-unused-expressions"]: {
|
|
15
|
-
allowShortCircuit: true,
|
|
16
|
-
allowTernary: true,
|
|
17
|
-
},
|
|
18
|
-
["no-unused-vars"]: {
|
|
19
|
-
vars: "all",
|
|
20
|
-
varsIgnorePattern: "^_",
|
|
21
|
-
args: "after-used",
|
|
22
|
-
argsIgnorePattern: "^_",
|
|
23
|
-
caughtErrors: "all",
|
|
24
|
-
reportUsedIgnorePattern: false,
|
|
25
|
-
// This pattern is pretty common
|
|
26
|
-
ignoreRestSiblings: true,
|
|
27
|
-
},
|
|
28
|
-
["@typescript-eslint/naming-convention"]: (() => {
|
|
29
|
-
const options = {
|
|
30
|
-
default: {
|
|
31
|
-
selector: "default",
|
|
32
|
-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
33
|
-
leadingUnderscore: "allow",
|
|
34
|
-
trailingUnderscore: "allow",
|
|
35
|
-
},
|
|
36
|
-
function: {
|
|
37
|
-
selector: "function",
|
|
38
|
-
format: ["camelCase"],
|
|
39
|
-
leadingUnderscore: "allow",
|
|
40
|
-
trailingUnderscore: "allow",
|
|
41
|
-
},
|
|
42
|
-
parameter: {
|
|
43
|
-
selector: "parameter",
|
|
44
|
-
format: ["camelCase", "PascalCase"],
|
|
45
|
-
leadingUnderscore: "allow",
|
|
46
|
-
trailingUnderscore: "allow",
|
|
47
|
-
},
|
|
48
|
-
method: {
|
|
49
|
-
selector: "method",
|
|
50
|
-
format: ["camelCase"],
|
|
51
|
-
leadingUnderscore: "allow",
|
|
52
|
-
trailingUnderscore: "allow",
|
|
53
|
-
},
|
|
54
|
-
typeLike: {
|
|
55
|
-
selector: "typeLike",
|
|
56
|
-
format: ["PascalCase"],
|
|
57
|
-
leadingUnderscore: "allow",
|
|
58
|
-
trailingUnderscore: "allow",
|
|
59
|
-
},
|
|
60
|
-
enumMember: {
|
|
61
|
-
selector: "enumMember",
|
|
62
|
-
format: ["PascalCase"],
|
|
63
|
-
leadingUnderscore: "allow",
|
|
64
|
-
trailingUnderscore: "allow",
|
|
65
|
-
},
|
|
66
|
-
// In case it's destructured, we don't want to force the developer to change the casing
|
|
67
|
-
destructuring: {
|
|
68
|
-
selector: "variable",
|
|
69
|
-
modifiers: ["destructured"],
|
|
70
|
-
format: null,
|
|
71
|
-
},
|
|
72
|
-
// In case the property name requires quotes, we don't enforce any convention
|
|
73
|
-
requiresQuites: {
|
|
74
|
-
selector: [
|
|
75
|
-
"classProperty",
|
|
76
|
-
"objectLiteralProperty",
|
|
77
|
-
"typeProperty",
|
|
78
|
-
"classMethod",
|
|
79
|
-
"objectLiteralMethod",
|
|
80
|
-
"typeMethod",
|
|
81
|
-
"accessor",
|
|
82
|
-
"enumMember",
|
|
83
|
-
],
|
|
84
|
-
modifiers: ["requiresQuotes"],
|
|
85
|
-
format: null,
|
|
86
|
-
},
|
|
87
|
-
// We don't enforce any convention on object literals since these are often used
|
|
88
|
-
// for data object where we're not in control of the type (e.g. an api that takes camel_case properties)
|
|
89
|
-
objectLiteralProperty: {
|
|
90
|
-
selector: "objectLiteralProperty",
|
|
91
|
-
format: null,
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// By enumerating all selectors explicitly we increase the
|
|
96
|
-
// specificity of these rules.
|
|
97
|
-
const escapeHatches = [
|
|
98
|
-
"variable",
|
|
99
|
-
"function",
|
|
100
|
-
"parameter",
|
|
101
|
-
"property",
|
|
102
|
-
"parameterProperty",
|
|
103
|
-
"method",
|
|
104
|
-
"accessor",
|
|
105
|
-
"enumMember",
|
|
106
|
-
"class",
|
|
107
|
-
"interface",
|
|
108
|
-
"typeAlias",
|
|
109
|
-
"enum",
|
|
110
|
-
"typeParameter",
|
|
111
|
-
].map((selector) => ({
|
|
112
|
-
filter: {
|
|
113
|
-
match: true,
|
|
114
|
-
// UNSAFE_ is a prefix used by React for all lifecycle hooks that are about to be deprecated
|
|
115
|
-
regex: "^(__|UNSAFE_).+$",
|
|
116
|
-
},
|
|
117
|
-
format: null,
|
|
118
|
-
selector,
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
...options,
|
|
123
|
-
defaultRules: [...Object.values(options), ...escapeHatches],
|
|
124
|
-
ignoreProperties: {
|
|
125
|
-
selector: "property",
|
|
126
|
-
format: null,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
})(),
|
|
130
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "../javascript-node.js";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//@ts-nocheck
|
|
2
|
-
// prettier-ignore
|
|
3
|
-
import { a } from "./other.js";
|
|
4
|
-
// eslint-disable-next-line no-duplicate-imports
|
|
5
|
-
import { b } from "./other.js";
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line array-callback-return
|
|
8
|
-
[1, 2, 3].reduce((memo, item, index) => {
|
|
9
|
-
memo[item] = index;
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
for (const number of [1, 2, 3]) {
|
|
13
|
-
// eslint-disable-next-line no-await-in-loop
|
|
14
|
-
await Promise.resolve(number);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
(class {
|
|
18
|
-
constructor() {
|
|
19
|
-
// eslint-disable-next-line no-constructor-return
|
|
20
|
-
return 1;
|
|
21
|
-
}
|
|
22
|
-
})();
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
25
|
-
void new Promise(() => 2);
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line no-self-compare
|
|
28
|
-
if (a === a) {
|
|
29
|
-
void (a, b);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
33
|
-
void "Hello ${name}!";
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line no-unmodified-loop-condition
|
|
36
|
-
while (a) {
|
|
37
|
-
void a;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// eslint-disable-next-line no-unreachable-loop
|
|
41
|
-
for (let index = 0; index < 3; index++) {
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line no-useless-assignment
|
|
46
|
-
let id = "x1234";
|
|
47
|
-
id = 2;
|
|
48
|
-
void id;
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
/* empty */
|
|
52
|
-
// eslint-disable-next-line unicorn/catch-error-name
|
|
53
|
-
} catch (bla) {
|
|
54
|
-
void bla;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let c = 1;
|
|
58
|
-
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
59
|
-
(async () => {
|
|
60
|
-
// eslint-disable-next-line require-atomic-updates
|
|
61
|
-
c += await c;
|
|
62
|
-
})();
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { Other } from "./Other.tsx";
|
|
3
|
-
|
|
4
|
-
export const App = (_props: { name: string; count: number }) => {
|
|
5
|
-
for (let index = 0; index < 10; index++) {
|
|
6
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
7
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
void index;
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
12
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
|
-
}, []);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line @eslint-react/naming-convention/use-state
|
|
17
|
-
const [state, updateState] = useState(0);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
21
|
-
updateState(1);
|
|
22
|
-
}, [state]);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
{/* eslint-disable-next-line jsx-a11y/alt-text */}
|
|
27
|
-
<img src="some-image.jpg" />
|
|
28
|
-
{/* eslint-disable-next-line react/jsx-curly-brace-presence */}
|
|
29
|
-
{"Hello world"}
|
|
30
|
-
{/* eslint-disable-next-line @eslint-react/no-leaked-conditional-rendering */}
|
|
31
|
-
<>{_props.count && <view />}</>
|
|
32
|
-
<Other />
|
|
33
|
-
</>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
38
|
-
export const doesntWorkWithHmr = () => {};
|
|
39
|
-
|
|
40
|
-
export const InvalidRefAccessDuringRender = () => {
|
|
41
|
-
const ref = useRef(null);
|
|
42
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
43
|
-
const value = ref.current;
|
|
44
|
-
return value;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
<App name="John" count={0} />;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "../typescript-react.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "../typescript-node.js";
|