@prowise/eslint-config-linting-rules 2.0.7 → 2.1.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 +69 -22
- package/eslint.back.js +9 -0
- package/next.js +24 -0
- package/package.json +1 -1
- package/rules/plugin-next-rules.js +147 -0
- package/rules/plugin-react-rules.js +5 -1
package/README.md
CHANGED
|
@@ -14,35 +14,82 @@ Rules are based on:
|
|
|
14
14
|
## How to use
|
|
15
15
|
|
|
16
16
|
* Install this package with `npm install @prowise/eslint-config-linting-rules -D`
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* Create a `eslint.config.js` file in the root folder of your project
|
|
18
|
+
* Depending on the type of project import one of the predefined flavours:
|
|
19
|
+
* Plain javascript project: `import base from "@prowise/eslint-config-linting-rules"`
|
|
20
|
+
* Typescript project: `import typescript from "@prowise/eslint-config-linting-rules/typescript"`
|
|
21
|
+
* Node-typescript backend project: `import backend from "@prowise/eslint-config-linting-rules/backend"`
|
|
22
|
+
* React-typescript frontend project: `import frontend from "@prowise/eslint-config-linting-rules/frontend"`
|
|
23
|
+
* Export the settings/rules, for example `export default frontend` for a frontend project.
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
If You want to add or overrule some settings you can add those by spreading the imported flavour and add the additions or overrides like the following examples.
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
NOTE: If you have a typescript project, you need to point to a `tsconfig.json` file which includes all the files which ESLint needs to check.
|
|
28
|
+
|
|
29
|
+
Sample of a `eslint.config.js` file for a backend project using node and typescript:
|
|
26
30
|
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
import backend from "@prowise/eslint-config-linting-rules/backend";
|
|
32
|
+
|
|
33
|
+
export default [...backend, {
|
|
34
|
+
ignores: [
|
|
35
|
+
"/**/reports",
|
|
36
|
+
"/dist",
|
|
37
|
+
],
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parserOptions: { project: "./tsconfig.json" },
|
|
31
40
|
},
|
|
32
|
-
};
|
|
41
|
+
}];
|
|
33
42
|
|
|
34
43
|
```
|
|
35
|
-
## Know issues
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
Sample of a `eslint.config.js` file for a frontend project using react and typescript:
|
|
46
|
+
```
|
|
47
|
+
import backend from "@prowise/eslint-config-linting-rules/frontend";
|
|
48
|
+
|
|
49
|
+
export default [...frontend, {
|
|
50
|
+
ignores: [
|
|
51
|
+
"/**/reports",
|
|
52
|
+
"/dist",
|
|
53
|
+
],
|
|
54
|
+
languageOptions: {
|
|
55
|
+
parserOptions: { project: "./tsconfig.json" },
|
|
56
|
+
},
|
|
57
|
+
}];
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Additional information can be found at: https://eslint.org/docs/latest/use/getting-started
|
|
62
|
+
|
|
39
63
|
|
|
40
|
-
|
|
64
|
+
## Migrating from version 1 (eslint <= 8.*.*)
|
|
65
|
+
|
|
66
|
+
Version 2 of this library uses ESlint >= 9.*.*. This version of ESLint uses flat configuration which means that it only reads 1 configuration file in the root folder of your project.
|
|
67
|
+
You need to remove all `.eslintrc` and `.eslintignore` files from all sub folders and add the configuration to the main `eslint.config.js` file.
|
|
68
|
+
|
|
69
|
+
If you want different configuration for the different folders yo can use the following config as example:
|
|
70
|
+
```
|
|
71
|
+
import frontend from "@prowise/eslint-config-linting-rules/frontend";
|
|
72
|
+
|
|
73
|
+
export default [...frontend,
|
|
74
|
+
{
|
|
75
|
+
ignores: [
|
|
76
|
+
"/**/reports",
|
|
77
|
+
"/dist",
|
|
78
|
+
],
|
|
79
|
+
languageOptions: {
|
|
80
|
+
parserOptions: { project: "./tsconfig.json" },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
files: ["tests/**/*],
|
|
85
|
+
rules: {
|
|
86
|
+
jsdoc/require-jsdoc: "off",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
```
|
|
41
92
|
|
|
42
|
-
|
|
43
|
-
When trying to update the installed lining version by `npm i -D "@prowise/eslint-config-linting-rules@latest` you might get an error on a peer dependency.
|
|
44
|
-
In this case you can uninstall the linter by `npm uninstall "@prowise/eslint-config-linting-rules` and reinstall it again with `npm i -D "@prowise/eslint-config-linting-rules@latest`
|
|
93
|
+
As you can see, the overrides are applicable to the files given in the `files` attribute. When you leave it undefined it applies to all files selected by the run command.
|
|
45
94
|
|
|
46
|
-
|
|
47
|
-
This version contains several breaking changes. This version is only tested on a backend project.
|
|
48
|
-
For the moment: DO NOT USE this version on a frontend project! You best use the latest version 1.2.13
|
|
95
|
+
For additional information see the official documentation on https://eslint.org/docs/latest/use/configure/migration-guide
|
package/eslint.back.js
ADDED
package/next.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import base from "./base.js";
|
|
3
|
+
import next from "./rules/plugin-next-rules.js";
|
|
4
|
+
import react from "./rules/plugin-react-rules.js";
|
|
5
|
+
import typescript from "./rules/plugin-typescript-rules.js";
|
|
6
|
+
import vitest from "./rules/plugin-vitest-rules.js";
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
base,
|
|
10
|
+
typescript,
|
|
11
|
+
react,
|
|
12
|
+
next,
|
|
13
|
+
vitest,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.browser,
|
|
18
|
+
...globals.node,
|
|
19
|
+
Atomics: "readonly",
|
|
20
|
+
SharedArrayBuffer: "readonly",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@prowise/eslint-config-linting-rules","version":"2.
|
|
1
|
+
{"name":"@prowise/eslint-config-linting-rules","version":"2.1.1","description":"Default Prowise linting rules for npm packages.","main":"index.js","type":"module","exports":{"./typescript":"./typescript.js","./backend":"./backend.js","./front-react":"./front-react.js","./front-solid":"./front-solid.js","./next":"./next.js"},"scripts":{"lint":"eslint","inspect":"eslint --inspect-config"},"repository":{"type":"git","url":"git+ssh://git@bitbucket.org/prowise/npm-linting-rules.git"},"author":"Prowise B.V.","license":"UNLICENSED","homepage":"https://bitbucket.org/prowise/npm-linting-rules#readme","dependencies":{"@next/eslint-plugin-next":"^15.1.0","@stylistic/eslint-plugin":"^2.12.1","confusing-browser-globals":"^1.0.11","eslint":"^9.17.0","eslint-import-resolver-typescript":"^3.7.0","eslint-plugin-import-x":"^4.5.0","eslint-plugin-jest":"^28.9.0","eslint-plugin-jsdoc":"^50.6.1","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-n":"^17.15.0","eslint-plugin-prefer-arrow-functions":"^3.4.1","eslint-plugin-react":"^7.37.2","eslint-plugin-react-hooks":"^5.1.0","eslint-plugin-solid":"^0.14.5","eslint-plugin-vitest":"^0.5.4","globals":"^15.13.0","typescript-eslint":"^8.18.1"},"devDependencies":{"@eslint/config-inspector":"^0.6.0"}}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import nextPlugin from "@next/eslint-plugin-next";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* ✅ recommended
|
|
5
|
+
* 🔒 strict
|
|
6
|
+
* 🔧 fixable
|
|
7
|
+
* 💡 has suggestion
|
|
8
|
+
* 💭 requires type information
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
plugins: {
|
|
13
|
+
next: nextPlugin,
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
rules: {
|
|
17
|
+
// warnings
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enforce font-display behavior with Google Fonts.
|
|
21
|
+
* https://nextjs.org/docs/messages/google-font-display
|
|
22
|
+
*/
|
|
23
|
+
"next/google-font-display": "warn",
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Ensure preconnect is used with Google Fonts.
|
|
27
|
+
* https://nextjs.org/docs/messages/google-font-preconnect
|
|
28
|
+
*/
|
|
29
|
+
"next/google-font-preconnect": "warn",
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Prefer next/script component when using the inline script for Google Analytics.
|
|
33
|
+
* https://nextjs.org/docs/messages/next-script-for-ga
|
|
34
|
+
*/
|
|
35
|
+
"next/next-script-for-ga": "warn",
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Prevent client components from being async functions.
|
|
39
|
+
* https://nextjs.org/docs/messages/no-async-client-component
|
|
40
|
+
*/
|
|
41
|
+
"next/no-async-client-component": "warn",
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Prevent usage of next/script's beforeInteractive strategy outside of pages/_document.js.
|
|
45
|
+
* https://nextjs.org/docs/messages/no-before-interactive-script-outside-document
|
|
46
|
+
*/
|
|
47
|
+
"next/no-before-interactive-script-outside-document": "warn",
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Prevent manual stylesheet tags.
|
|
51
|
+
* https://nextjs.org/docs/messages/no-css-tags
|
|
52
|
+
*/
|
|
53
|
+
"next/no-css-tags": "warn",
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Prevent usage of <head> element.
|
|
57
|
+
* https://nextjs.org/docs/messages/no-head-element
|
|
58
|
+
*/
|
|
59
|
+
"next/no-head-element": "warn",
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Prevent usage of <a> elements to navigate to internal Next.js pages.
|
|
63
|
+
* https://nextjs.org/docs/messages/no-html-link-for-pages
|
|
64
|
+
*/
|
|
65
|
+
"next/no-html-link-for-pages": "warn",
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Prevent usage of <img> element due to slower LCP and higher bandwidth.
|
|
69
|
+
* https://nextjs.org/docs/messages/no-img-element
|
|
70
|
+
*/
|
|
71
|
+
"next/no-img-element": "warn",
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Prevent page-only custom fonts.
|
|
75
|
+
* https://nextjs.org/docs/messages/no-page-custom-font
|
|
76
|
+
*/
|
|
77
|
+
"next/no-page-custom-font": "warn",
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Prevent usage of styled-jsx in pages/_document.js.
|
|
81
|
+
* https://nextjs.org/docs/messages/no-styled-jsx-in-document
|
|
82
|
+
*/
|
|
83
|
+
"next/no-styled-jsx-in-document": "warn",
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Prevent synchronous scripts.
|
|
87
|
+
* https://nextjs.org/docs/messages/no-sync-scripts
|
|
88
|
+
*/
|
|
89
|
+
"next/no-sync-scripts": "warn",
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Prevent usage of <title> with Head component from next/document.
|
|
93
|
+
* https://nextjs.org/docs/messages/no-title-in-document-head
|
|
94
|
+
*/
|
|
95
|
+
"next/no-title-in-document-head": "warn",
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Prevent common typos in Next.js's data fetching functions
|
|
99
|
+
* https://nextjs.org/docs
|
|
100
|
+
*/
|
|
101
|
+
"next/no-typos": "warn",
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Prevent duplicate polyfills from Polyfill.io.
|
|
105
|
+
* https://nextjs.org/docs/messages/no-unwanted-polyfillio
|
|
106
|
+
*/
|
|
107
|
+
"next/no-unwanted-polyfillio": "warn",
|
|
108
|
+
|
|
109
|
+
// errors
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Enforce id attribute on next/script components with inline content
|
|
113
|
+
* https://nextjs.org/docs/messages/inline-script-id
|
|
114
|
+
*/
|
|
115
|
+
"next/inline-script-id": "error",
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Prevent assignment to the module variable.
|
|
119
|
+
* https://nextjs.org/docs/messages/no-assign-module-variable
|
|
120
|
+
*/
|
|
121
|
+
"next/no-assign-module-variable": "error",
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Prevent importing next/document outside of pages/_document.js
|
|
125
|
+
* https://nextjs.org/docs/messages/no-document-import-in-page
|
|
126
|
+
*/
|
|
127
|
+
"next/no-document-import-in-page": "error",
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Prevent duplicate usage of <Head> in pages/_document.js
|
|
131
|
+
* https://nextjs.org/docs/messages/no-duplicate-head
|
|
132
|
+
*/
|
|
133
|
+
"next/no-duplicate-head": "error",
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Prevent usage of next/head in pages/_document.js.
|
|
137
|
+
* https://nextjs.org/docs/messages/no-head-import-in-document
|
|
138
|
+
*/
|
|
139
|
+
"next/no-head-import-in-document": "error",
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Prevent usage of next/script in next/head component.
|
|
143
|
+
* https://nextjs.org/docs/messages/no-script-component-in-head
|
|
144
|
+
*/
|
|
145
|
+
"next/no-script-component-in-head": "error",
|
|
146
|
+
},
|
|
147
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import reactPlugin from "eslint-plugin-react";
|
|
2
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
/*
|
|
@@ -8,7 +9,8 @@ export default {
|
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
plugins: {
|
|
11
|
-
react: reactPlugin,
|
|
12
|
+
"react": reactPlugin,
|
|
13
|
+
"react-hooks": reactHooks,
|
|
12
14
|
},
|
|
13
15
|
|
|
14
16
|
rules: {
|
|
@@ -761,5 +763,7 @@ export default {
|
|
|
761
763
|
format: ["PascalCase"],
|
|
762
764
|
},
|
|
763
765
|
],
|
|
766
|
+
"react-hooks/rules-of-hooks": "error",
|
|
767
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
764
768
|
},
|
|
765
769
|
};
|