@prowise/eslint-config-linting-rules 3.0.14 → 4.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/README.md CHANGED
@@ -15,53 +15,57 @@ Rules are based on:
15
15
 
16
16
  * Install this package with `npm install @prowise/eslint-config-linting-rules -D`
17
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.
18
+ * Import the flavour for your project using the matching package subpath.
24
19
 
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.
26
-
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.
20
+ | Project | Subpath |
21
+ | --- | --- |
22
+ | TypeScript | `/typescript` |
23
+ | Node.js backend | `/backend` |
24
+ | React frontend | `/front-react` |
25
+ | Solid frontend | `/front-solid` |
26
+ | Next.js | `/next` |
28
27
 
29
28
  Sample of a `eslint.config.js` file for a backend project using node and typescript:
30
- ```
29
+ ```js
31
30
  import backend from "@prowise/eslint-config-linting-rules/backend";
32
31
 
33
32
  export default [
34
33
  { ignores: [ "**/reports", "**/dist/"] },
35
34
 
36
35
  ...backend,
37
-
38
- { languageOptions: {
39
- parserOptions: { project: "./tsconfig.json" },
36
+ {
37
+ /* when files is omitted then it goes for all files */
38
+ files: [ /* file pattern on which the overrides are applied */ ]
39
+ rules: {
40
+ /* overrides of rules go here */
41
+ }
40
42
  },
41
- }];
42
-
43
+ ];
43
44
  ```
44
45
 
45
- Sample of a `eslint.config.js` file for a react frontend project using react and typescript:
46
- ```
47
- import frontend from "@prowise/eslint-config-linting-rules/front-react";
48
46
 
49
- export default [
50
- { ignores: [ "**/reports", "**/dist/"] },
47
+ Or you can also use ESLint's `defineConfig()`, followed by your overrides, `globalIgnores()` and the rule overrides.
51
48
 
52
- ...frontend,
53
- { languageOptions: {
54
- parserOptions: { project: "./tsconfig.json" },
55
- },
56
- }];
49
+ ```js
50
+ import backend from "@prowise/eslint-config-linting-rules/backend";
51
+ import { defineConfig, globalIgnores } from "eslint/config";
57
52
 
53
+ export default defineConfig(
54
+ backend,
55
+ globalIgnores(["**/dist/", "**/generated/", "tests/**/results/"]),
56
+ {
57
+ rules: .....
58
+ }
59
+ );
58
60
  ```
59
61
 
60
- Additional information can be found at: https://eslint.org/docs/latest/use/getting-started
62
+ The backend preset allows explicit `any` in `*.test.ts` and `*.test.tsx` files and disables `no-await-in-loop` across the project. For type-aware linting, make sure the relevant TypeScript files are included in your project's `tsconfig.json`.
63
+
64
+ [ESLint documentation on global ignores](https://eslint.org/docs/latest/use/configure/ignore)
61
65
 
62
66
  ## Inspect your configuration
63
67
 
64
- ESLint version 9 comes with a nice inspector to verify your settings. It can be opened by installing it as a global node app together with eslint:
68
+ ESLint version > 9 comes with a nice inspector to verify your settings. It can be opened by installing it as a global node app together with eslint:
65
69
  ```
66
70
  npm i -g eslint @eslint/config-inspector
67
71
  ```
@@ -73,30 +77,38 @@ Or just run it from the command line without installing it first by `npx @eslint
73
77
  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.
74
78
  You need to remove all `.eslintrc` and `.eslintignore` files from all sub folders and add the configuration to the main `eslint.config.js` file.
75
79
 
76
- If you want different configuration for the different folders yo can use the following config as example:
77
- ```
78
- import frontend from "@prowise/eslint-config-linting-rules/front-react";
79
-
80
- export default [
81
- // IGNORES MUST BE ON TOP !
82
- { ignores: [ "**/reports", "**/dist/"] },
83
-
84
- ...frontend,
85
-
86
- { languageOptions: {
87
- parserOptions: { project: "./tsconfig.json" },
88
- },
89
- },
90
- {
91
- files: ["tests/**/*],
92
- rules: {
93
- jsdoc/require-jsdoc: "off",
94
- },
95
- },
96
- ];
97
-
98
- ```
99
-
100
- 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.
101
-
102
- For additional information see the official documentation on https://eslint.org/docs/latest/use/configure/migration-guide
80
+ Add an override with a `files` pattern after the preset to apply different rules to specific folders or file types. Omit `files` to apply the override to every linted file.
81
+
82
+ [ESLint configuration migration guide](https://eslint.org/docs/latest/use/configure/migration-guide)
83
+
84
+
85
+ ## Migration to version 4
86
+
87
+ Version 4 of this library contains new rules to validate known security issues. The following plugins are added with the recommended rules enabled.
88
+
89
+ - On both front and backend:
90
+ - https://eslint.interlace.tools/docs/security/plugin-jwt-security: JWT verification, alg none and weak secret checks
91
+ - On the backend projects:
92
+ - https://eslint.interlace.tools/docs/security/plugin-node-security: Node.js child_process, fs, vm and crypto security
93
+ - https://eslint.interlace.tools/docs/security/plugin-typeorm-security: SQL injection in raw queries
94
+ - https://eslint.interlace.tools/docs/security/plugin-express-security: Express CORS, CSRF, cookie and Helmet checks
95
+ - On frontend projects:
96
+ - https://eslint.interlace.tools/docs/security/plugin-browser-security: detect XSS, postMessage and cookie leaks in the browser
97
+
98
+ Updated all dependencies and plugins which lead to breaking changes:
99
+
100
+ | Rules | Change |
101
+ | --- | --- |
102
+ | `style/line-length` | Max 160 (auto-fix) |
103
+ | `style/array` | Max 25 items on one line, or line length < 160 (auto-fix) |
104
+ | `style/object` | Max 9 items on one line, or line length < 160 (auto-fix) |
105
+ | `import/named-import-layout` | Single line up to 8 items or length < 160: settings are configurable (auto-fix) |
106
+ | `import/order` | Order of relative paths changed: `./`, `../` `../../` etc... (auto-fix) |
107
+ | `jsx/jsx-element-pascal-case` | Rule renamed to `style/jsx-pascal-case` |
108
+ | `jsdoc-x/newline-before-return` | Rule renamed to `jsdoc/newline-before-returns` |
109
+ | `jsdoc-x/optional-param-brackets` | Rule renamed to `jsdoc/optional-param-brackets` |
110
+ | `jsdoc-x/single-line` | Rule renamed to `jsdoc/single-line` |
111
+ | `jsdoc/require-jsdoc` | Turned off by default for test files |
112
+ | `typescript/no-explicit-any` | Turned off by default for test files |
113
+ | `typescript/no-unsafe-return` | Turned off by default for test files |
114
+ | `typescript/no-confusing-void-expression` | Turned off by default for test files|
package/backend.js CHANGED
@@ -1,6 +1,18 @@
1
- import base from "./base.js";
1
+ import base, { typescriptTestOverrides } from "./base.js";
2
+ import expressSecurity from "./rules/plugin-express-security.js";
2
3
  import node from "./rules/plugin-node-rules.js";
4
+ import nodeSecurity from "./rules/plugin-node-security.js";
5
+ import typeormSecurity from "./rules/plugin-typeorm-security.js";
3
6
  import typescript from "./rules/plugin-typescript-rules.js";
4
7
  import vitest from "./rules/plugin-vitest-rules.js";
5
8
 
6
- export default [base, node, typescript, vitest];
9
+ export default [
10
+ base,
11
+ node,
12
+ nodeSecurity,
13
+ expressSecurity,
14
+ typeormSecurity,
15
+ typescript,
16
+ vitest,
17
+ typescriptTestOverrides,
18
+ ];
package/base.js CHANGED
@@ -1,13 +1,25 @@
1
1
  /*
2
2
  * Basic rules for all javascript projects
3
3
  */
4
+ import progress from "./custom-rules/file-progress.js";
4
5
  import base from "./rules/baseSettings.js";
5
- import progress from "./rules/file-progress.js";
6
6
  import imports from "./rules/plugin-import-rules.js";
7
7
  import jsDoc from "./rules/plugin-jsdoc-rules.js";
8
+ import jwtSecurity from "./rules/plugin-jwt-security.js";
8
9
  import preferArrow from "./rules/plugin-prefer-arrow-rules.js";
9
10
  import style from "./rules/plugin-stylistic-rules.js";
10
11
 
12
+ export const typescriptTestOverrides = {
13
+ files: ["**/*.test.{ts,tsx}", "tests/**/*.{js,ts,jsx,tsx}"],
14
+ rules: {
15
+ "jsdoc/require-jsdoc": "off",
16
+ "typescript/no-explicit-any": "off",
17
+ "typescript/no-unsafe-return": "off",
18
+ "typescript/no-confusing-void-expression": "off",
19
+ "browser-security/no-insecure-websocket": "off",
20
+ },
21
+ };
22
+
11
23
  export default {
12
24
  languageOptions: {
13
25
  ecmaVersion: "latest",
@@ -21,6 +33,7 @@ export default {
21
33
  ...imports.plugins,
22
34
  ...jsDoc.plugins,
23
35
  ...preferArrow.plugins,
36
+ ...jwtSecurity.plugins,
24
37
  },
25
38
 
26
39
  rules: {
@@ -30,6 +43,7 @@ export default {
30
43
  ...imports.rules,
31
44
  ...jsDoc.rules,
32
45
  ...preferArrow.rules,
46
+ ...jwtSecurity.rules,
33
47
  },
34
48
  settings: {
35
49
  progress: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Enforce a blank JSDoc line immediately before the @returns tag.
3
3
  */
4
- export default {
4
+ export const jsdocNewlineBeforeReturns = {
5
5
  meta: {
6
6
  type: "layout",
7
7
  docs: {
@@ -3,7 +3,7 @@
3
3
  * When a parameter has a `?` in its TypeScript signature or has a default value,
4
4
  * the JSDoc @param tag should use brackets: `@param [paramName]` instead of `@param paramName`.
5
5
  */
6
- export default {
6
+ export const jsdocOptionalParamBrackets = {
7
7
  meta: {
8
8
  type: "problem",
9
9
  docs: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Enforce single-line JSDoc comments to use inline format.
3
3
  */
4
- export default {
4
+ export const jsdocSingleLine = {
5
5
  meta: {
6
6
  type: "layout",
7
7
  docs: {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable jsdoc/require-jsdoc */
2
- export const jsxElementRule = {
2
+ export const jsxPascalCase = {
3
3
  meta: {
4
4
  type: "stylistic",
5
5
  docs: { description: "Enforce PascalCase for any function which returns a JSX element" },
@@ -18,7 +18,9 @@ export const jsxElementRule = {
18
18
  if (returnStatement) return getReturnType(returnStatement.argument);
19
19
 
20
20
  const switchStatement = body.body.find((stmt) => stmt.type === "SwitchStatement");
21
- if (switchStatement) return switchStatement.cases[0].consequent.find((stmt) => stmt.type === "ReturnStatement")?.argument.type;
21
+ if (switchStatement) {
22
+ return switchStatement.cases[0].consequent.find((stmt) => stmt.type === "ReturnStatement")?.argument?.type;
23
+ }
22
24
 
23
25
  return undefined;
24
26
  }
@@ -68,5 +70,3 @@ export const jsxElementRule = {
68
70
  };
69
71
  },
70
72
  };
71
-
72
- export default { rules: { "jsx-element-pascal-case": jsxElementRule } };
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Formats named imports on one line when possible, or one specifier per line otherwise.
3
+ */
4
+ export const namedImportLayout = {
5
+ meta: {
6
+ type: "layout",
7
+ docs: {
8
+ description: "require named imports to fit within the configured line and entry limits or use one specifier per line",
9
+ },
10
+ fixable: "whitespace",
11
+ schema: [
12
+ {
13
+ type: "object",
14
+ properties: {
15
+ maxLineLength: { type: "integer", minimum: 1 },
16
+ maxItemsPerLine: { type: "integer", minimum: 0 },
17
+ indentSize: { type: "integer", minimum: 0 },
18
+ },
19
+ additionalProperties: false,
20
+ },
21
+ ],
22
+ messages: {
23
+ incorrectLayout: "Use one line if at most {{maxItemsPerLine}} entries fit within {{maxLineLength}} characters.",
24
+ },
25
+ },
26
+ /**
27
+ * Creates the import declaration visitor.
28
+ *
29
+ * @param context - The ESLint rule context.
30
+ *
31
+ * @returns The visitor for named imports.
32
+ */
33
+ create: (context) => {
34
+ const { maxLineLength = 160, maxItemsPerLine = 8, indentSize = 4 } = context.options[0] ?? {};
35
+ const { sourceCode } = context;
36
+ const lineEnding = sourceCode.text.includes("\r\n") ? "\r\n" : "\n";
37
+
38
+ /**
39
+ * Builds the text before the named specifiers.
40
+ *
41
+ * @param node - The import declaration.
42
+ *
43
+ * @returns The import keyword and any type modifier or default specifier.
44
+ */
45
+ const getImportPrefix = (node) => {
46
+ const defaultSpecifier = node.specifiers.find((specifier) => specifier.type === "ImportDefaultSpecifier");
47
+ const importKind = node.importKind === "type" ? "type" : "";
48
+ const defaultImport = defaultSpecifier ? `${sourceCode.getText(defaultSpecifier)},` : "";
49
+
50
+ return ["import", importKind, defaultImport].filter(Boolean).join(" ");
51
+ };
52
+
53
+ /**
54
+ * Preserves the text after the module specifier.
55
+ *
56
+ * @param node - The import declaration.
57
+ *
58
+ * @returns The import attributes or assertions and statement terminator, when present.
59
+ */
60
+ const getSourceSuffix = (node) => {
61
+ const sourceTail = sourceCode.text.slice(node.source.range[1], node.range[1]).trim();
62
+
63
+ return sourceTail.startsWith("with") || sourceTail.startsWith("assert")
64
+ ? ` ${sourceTail}`
65
+ : sourceTail;
66
+ };
67
+
68
+ /**
69
+ * Formats the braced list of named specifiers.
70
+ *
71
+ * @param entries - The source text of each named specifier.
72
+ * @param availableWidth - The number of columns available for an inline list.
73
+ * @param indentation - The leading whitespace of the import declaration.
74
+ *
75
+ * @returns The formatted list including its opening and closing braces.
76
+ */
77
+ const formatBraces = (entries, availableWidth, indentation) => {
78
+ const inline = `{ ${entries.join(", ")} }`;
79
+ if (entries.length <= maxItemsPerLine && inline.length <= availableWidth && !/[\r\n\u2028\u2029]/u.test(inline)) {
80
+ return inline;
81
+ }
82
+
83
+ const entryIndentation = indentation + " ".repeat(indentSize);
84
+ const lines = entries.map((entry) => `${entryIndentation}${entry},`);
85
+ return ["{", ...lines, `${indentation}}`].join(lineEnding);
86
+ };
87
+
88
+ /**
89
+ * Reports and fixes an import whose layout differs from the expected text.
90
+ *
91
+ * @param node - The import declaration.
92
+ * @param range - The source offsets of the text to replace.
93
+ * @param expected - The formatted import text.
94
+ */
95
+ const reportLayout = (node, range, expected) => {
96
+ if (sourceCode.text.slice(...range) !== expected) {
97
+ context.report({
98
+ node,
99
+ messageId: "incorrectLayout",
100
+ data: { maxItemsPerLine, maxLineLength },
101
+ fix: (fixer) => fixer.replaceTextRange(range, expected),
102
+ });
103
+ }
104
+ };
105
+
106
+ return {
107
+ /**
108
+ * Checks imports with named specifiers and no internal comments.
109
+ *
110
+ * @param node - The import declaration.
111
+ */
112
+ ImportDeclaration: (node) => {
113
+ const namedSpecifiers = node.specifiers.filter((specifier) => specifier.type === "ImportSpecifier");
114
+
115
+ if (namedSpecifiers.length === 0 || sourceCode.getCommentsInside(node).length > 0) {
116
+ return;
117
+ }
118
+
119
+ const specifierText = namedSpecifiers.map((specifier) => sourceCode.getText(specifier));
120
+ const prefix = `${getImportPrefix(node)} `;
121
+ const suffix = ` from ${sourceCode.getText(node.source)}${getSourceSuffix(node)}`;
122
+ const { column } = node.loc.start;
123
+ const braces = formatBraces(
124
+ specifierText,
125
+ maxLineLength - column - prefix.length - suffix.length,
126
+ " ".repeat(column),
127
+ );
128
+ reportLayout(node, node.range, `${prefix}${braces}${suffix}`);
129
+ },
130
+ };
131
+ },
132
+ };
package/eslint.config.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import base from "./base.js";
2
- import jsx from "./rules/jsx-pascal-case-rule.js";
3
2
  import jsxA11y from "./rules/plugin-jsx-a11y-rules.js";
4
- // import next from "./rules/plugin-next-rules.js";
3
+ import next from "./rules/plugin-next-rules.js";
5
4
  import node from "./rules/plugin-node-rules.js";
5
+ import nodeSecurity from "./rules/plugin-node-security.js";
6
6
  import react from "./rules/plugin-react-rules.js";
7
+ import typeormSecurity from "./rules/plugin-typeorm-security.js";
7
8
  import typescript from "./rules/plugin-typescript-rules.js";
8
9
  import vitest from "./rules/plugin-vitest-rules.js";
9
10
 
@@ -12,16 +13,17 @@ import vitest from "./rules/plugin-vitest-rules.js";
12
13
  export default [
13
14
  base,
14
15
  node,
16
+ nodeSecurity,
15
17
  typescript,
18
+ typeormSecurity,
16
19
  vitest,
17
20
  react,
18
- // next,
21
+ next,
19
22
  jsxA11y,
20
23
  {
21
- plugins: { jsx },
22
24
  rules: {
23
25
  "import/no-named-as-default-member": "off",
24
26
  "import/no-named-as-default": "off",
25
- "jsx/jsx-element-pascal-case": "error",
26
27
  },
27
- }];
28
+ },
29
+ ];
package/front-react.js CHANGED
@@ -1,17 +1,20 @@
1
1
  import globals from "globals";
2
- import base from "./base.js";
3
- import jsx from "./rules/jsx-pascal-case-rule.js";
2
+ import base, { typescriptTestOverrides } from "./base.js";
3
+ import browserSecurity from "./rules/plugin-browser-security.js";
4
+ import jsxA11y from "./rules/plugin-jsx-a11y-rules.js";
4
5
  import react from "./rules/plugin-react-rules.js";
5
6
  import typescript from "./rules/plugin-typescript-rules.js";
6
7
  import vitest from "./rules/plugin-vitest-rules.js";
7
8
 
8
9
  export default [
9
10
  base,
11
+ browserSecurity,
10
12
  typescript,
11
13
  react,
14
+ jsxA11y,
12
15
  vitest,
13
16
  {
14
- plugins: { typescript: typescript.plugins.typescript, jsx },
17
+ plugins: { typescript: typescript.plugins.typescript },
15
18
  settings: { react: { version: "detect" } },
16
19
  languageOptions: {
17
20
  globals: {
@@ -27,7 +30,7 @@ export default [
27
30
  { selector: "variable", format: ["camelCase", "PascalCase", "UPPER_CASE"] },
28
31
  { selector: "typeLike", format: ["PascalCase"] },
29
32
  ],
30
- "jsx/jsx-element-pascal-case": "error",
31
33
  },
32
34
  },
35
+ typescriptTestOverrides,
33
36
  ];
package/front-solid.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import globals from "globals";
2
- import base from "./base.js";
2
+ import base, { typescriptTestOverrides } from "./base.js";
3
+ import browserSecurity from "./rules/plugin-browser-security.js";
4
+ // import jsxA11y from "./rules/plugin-jsx-a11y-rules.js";
3
5
  import typescript from "./rules/plugin-typescript-rules.js";
4
6
  import vitest from "./rules/plugin-vitest-rules.js";
5
7
 
6
8
  export default [
7
9
  base,
10
+ browserSecurity,
11
+ // jsxA11y,
8
12
  typescript,
9
13
  vitest,
10
14
  {
@@ -16,4 +20,5 @@ export default [
16
20
  },
17
21
  },
18
22
  },
23
+ typescriptTestOverrides,
19
24
  ];
package/next.js CHANGED
@@ -1,19 +1,22 @@
1
1
  import globals from "globals";
2
- import base from "./base.js";
3
- import jsx from "./rules/jsx-pascal-case-rule.js";
4
- // import next from "./rules/plugin-next-rules.js";
2
+ import base, { typescriptTestOverrides } from "./base.js";
3
+ import browserSecurity from "./rules/plugin-browser-security.js";
4
+ import jsxA11y from "./rules/plugin-jsx-a11y-rules.js";
5
+ import next from "./rules/plugin-next-rules.js";
5
6
  import react from "./rules/plugin-react-rules.js";
6
7
  import typescript from "./rules/plugin-typescript-rules.js";
7
8
  import vitest from "./rules/plugin-vitest-rules.js";
8
9
 
9
10
  export default [
10
11
  base,
12
+ browserSecurity,
11
13
  typescript,
12
14
  react,
13
- // next, (disabled due to high vulnerability)
15
+ jsxA11y,
16
+ next,
14
17
  vitest,
15
18
  {
16
- plugins: { typescript: typescript.plugins.typescript, jsx },
19
+ plugins: { typescript: typescript.plugins.typescript },
17
20
  settings: { react: { version: "detect" } },
18
21
  languageOptions: {
19
22
  globals: {
@@ -30,7 +33,7 @@ export default [
30
33
  { selector: "variable", format: ["camelCase", "PascalCase", "UPPER_CASE"] },
31
34
  { selector: "typeLike", format: ["PascalCase"] },
32
35
  ],
33
- "jsx/jsx-element-pascal-case": "error",
34
36
  },
35
37
  },
38
+ typescriptTestOverrides,
36
39
  ];
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@prowise/eslint-config-linting-rules","version":"3.0.14","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","test":"node tests/*.test.js","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":{"@eslint-react/eslint-plugin":"^5.28.8","@htmlacademy/eslint-plugin-jsx-a11y":"^6.11.0","@stylistic/eslint-plugin":"^5.10.0","@vitest/eslint-plugin":"^1.6.28","confusing-browser-globals":"^1.0.11","eslint":"^10.14.0","eslint-import-resolver-typescript":"^4.4.5","eslint-plugin-import-x":"^4.18.1","eslint-plugin-jsdoc":"^65.4.2","eslint-plugin-n":"^18.5.0","eslint-plugin-prefer-arrow-functions":"^3.10.2","globals":"^17.14.0","nanospinner":"^1.2.2","typescript-eslint":"^8.72.1"},"devDependencies":{"@eslint/config-inspector":"^3.5.0"},"overrides":{"minimatch":"^11.0.5"},"allowScripts":{"unrs-resolver":true}}
1
+ {"name":"@prowise/eslint-config-linting-rules","version":"4.0.0","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","test":"node --test tests/*.test.js","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":{"@eslint-react/eslint-plugin":"^5.30.7","@htmlacademy/eslint-plugin-jsx-a11y":"^6.11.0","@next/eslint-plugin-next":"^16.4.6","@stylistic/eslint-plugin":"^6.0.1","@vitest/eslint-plugin":"^1.6.28","confusing-browser-globals":"^1.0.11","eslint":"^10.16.0","eslint-import-resolver-typescript":"^4.4.5","eslint-plugin-browser-security":"^3.1.8","eslint-plugin-express-security":"^4.4.6","eslint-plugin-import-x":"^4.18.1","eslint-plugin-jsdoc":"^65.6.2","eslint-plugin-jwt-security":"^4.0.13","eslint-plugin-n":"^18.6.0","eslint-plugin-node-security":"^6.3.13","eslint-plugin-prefer-arrow-functions":"^3.10.2","eslint-plugin-typeorm-security":"^2.0.5","globals":"^17.14.0","nanospinner":"^1.2.2","typescript-eslint":"^8.74.0"},"devDependencies":{"@eslint/config-inspector":"^3.5.0"},"allowScripts":{"unrs-resolver":true}}
@@ -0,0 +1,16 @@
1
+ import browserSecurityPlugin from "eslint-plugin-browser-security";
2
+
3
+ export default {
4
+ /*
5
+ * ✅ recommended
6
+ * 🔒 strict
7
+ * 🔧 fixable
8
+ * 💡 has suggestion
9
+ * 💭 requires type information
10
+ */
11
+ plugins: {
12
+ "browser-security": browserSecurityPlugin,
13
+ },
14
+
15
+ rules: browserSecurityPlugin.configs.recommended.rules,
16
+ };
@@ -0,0 +1,16 @@
1
+ import expressSecurityPlugin from "eslint-plugin-express-security";
2
+
3
+ export default {
4
+ /*
5
+ * ✅ recommended
6
+ * 🔒 strict
7
+ * 🔧 fixable
8
+ * 💡 has suggestion
9
+ * 💭 requires type information
10
+ */
11
+ plugins: {
12
+ "express-security": expressSecurityPlugin,
13
+ },
14
+
15
+ rules: expressSecurityPlugin.configs.recommended.rules,
16
+ };
@@ -1,4 +1,5 @@
1
1
  import importPlugin from "eslint-plugin-import-x";
2
+ import { namedImportLayout } from "../custom-rules/named-import-layout.js";
2
3
 
3
4
  export default {
4
5
  /*
@@ -9,7 +10,7 @@ export default {
9
10
  * 💭 requires type information
10
11
  */
11
12
 
12
- plugins: { import: importPlugin },
13
+ plugins: { import: { ...importPlugin, rules: { ...importPlugin.rules, "named-import-layout": namedImportLayout } } },
13
14
 
14
15
  rules: {
15
16
  /**
@@ -142,22 +143,33 @@ export default {
142
143
  "import/no-webpack-loader-syntax": "error",
143
144
 
144
145
  /**
145
- * Ensure absolute imports are above relative imports and that unassigned imports are ignored. 🔧
146
+ * Sort absolute imports together, followed by sibling, index, and parent imports. Ignore unassigned imports. 🔧
146
147
  * https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md.
147
148
  */
148
149
  "import/order": [
149
150
  "error",
150
151
  {
151
- groups: [["builtin", "external", "internal"], ["sibling", "parent", "index"]],
152
+ groups: [["builtin", "external", "internal"], "sibling", "index", "parent"],
152
153
  pathGroups: [
153
154
  {
154
155
  pattern: "react",
155
156
  group: "external",
156
157
  position: "before",
157
158
  },
159
+ {
160
+ pattern: "{..,../**}",
161
+ patternOptions: { dot: true },
162
+ group: "parent",
163
+ position: "before",
164
+ },
158
165
  ],
159
166
  alphabetize: { order: "asc", caseInsensitive: true },
160
167
  },
161
168
  ],
169
+
170
+ /**
171
+ * Formats named imports on one line when possible, or one specifier per line otherwise.
172
+ */
173
+ "import/named-import-layout": "error",
162
174
  },
163
175
  };
@@ -1,7 +1,7 @@
1
1
  import jsdocPlugin from "eslint-plugin-jsdoc";
2
- import jsdocNewlineBeforeReturns from "./jsdoc-newline-before-returns.js";
3
- import jsdocOptionalParamBrackets from "./jsdoc-optional-param-brackets.js";
4
- import jsdocSingleLine from "./jsdoc-single-line.js";
2
+ import { jsdocNewlineBeforeReturns } from "../custom-rules/jsdoc-newline-before-returns.js";
3
+ import { jsdocOptionalParamBrackets } from "../custom-rules/jsdoc-optional-param-brackets.js";
4
+ import { jsdocSingleLine } from "../custom-rules/jsdoc-single-line.js";
5
5
 
6
6
  export default {
7
7
  /*
@@ -13,9 +13,10 @@ export default {
13
13
  */
14
14
 
15
15
  plugins: {
16
- "jsdoc": jsdocPlugin,
17
- "jsdoc-x": {
16
+ jsdoc: {
17
+ ...jsdocPlugin,
18
18
  rules: {
19
+ ...jsdocPlugin.rules,
19
20
  "newline-before-returns": jsdocNewlineBeforeReturns,
20
21
  "optional-param-brackets": jsdocOptionalParamBrackets,
21
22
  "single-line": jsdocSingleLine,
@@ -305,18 +306,18 @@ export default {
305
306
  /**
306
307
  * Enforce a blank JSDoc line immediately before the @returns tag.
307
308
  */
308
- "jsdoc-x/newline-before-returns": "off",
309
+ "jsdoc/newline-before-returns": "off",
309
310
 
310
311
  /**
311
312
  * Enforce brackets around optional parameter names in JSDoc @param tags.
312
313
  * When a parameter has a `?` in its TypeScript signature or has a default value,
313
314
  * the JSDoc @param tag should use brackets: `@param [paramName]` instead of `@param paramName`.
314
315
  */
315
- "jsdoc-x/optional-param-brackets": "off",
316
+ "jsdoc/optional-param-brackets": "off",
316
317
 
317
318
  /**
318
319
  * Enforce single-line JSDoc comments to use inline format.
319
320
  */
320
- "jsdoc-x/single-line": "off",
321
+ "jsdoc/single-line": "off",
321
322
  },
322
323
  };
@@ -0,0 +1,16 @@
1
+ import jwtSecurityPlugin from "eslint-plugin-jwt-security";
2
+
3
+ export default {
4
+ /*
5
+ * ✅ recommended
6
+ * 🔒 strict
7
+ * 🔧 fixable
8
+ * 💡 has suggestion
9
+ * 💭 requires type information
10
+ */
11
+ plugins: {
12
+ "jwt-security": jwtSecurityPlugin,
13
+ },
14
+
15
+ rules: jwtSecurityPlugin.configs.recommended.rules,
16
+ };
@@ -1,4 +1,4 @@
1
- // import nextPlugin from "@next/eslint-plugin-next";
1
+ import nextPlugin from "@next/eslint-plugin-next";
2
2
 
3
3
  export default {
4
4
  /*
@@ -10,7 +10,7 @@ export default {
10
10
  */
11
11
 
12
12
  plugins: {
13
- // next: nextPlugin,
13
+ next: nextPlugin,
14
14
  },
15
15
 
16
16
  rules: {
@@ -0,0 +1,16 @@
1
+ import nodeSecurityPlugin from "eslint-plugin-node-security";
2
+
3
+ export default {
4
+ /*
5
+ * ✅ recommended
6
+ * 🔒 strict
7
+ * 🔧 fixable
8
+ * 💡 has suggestion
9
+ * 💭 requires type information
10
+ */
11
+ plugins: {
12
+ "node-security": nodeSecurityPlugin,
13
+ },
14
+
15
+ rules: nodeSecurityPlugin.configs.recommended.rules,
16
+ };
@@ -1,17 +1,10 @@
1
1
  import stylePlugin from "@stylistic/eslint-plugin";
2
+ import { jsxPascalCase } from "../custom-rules/jsx-pascal-case.js";
2
3
 
3
4
  export default {
4
- plugins: {
5
- style: stylePlugin,
6
- },
5
+ plugins: { style: { ...stylePlugin, rules: { ...stylePlugin.rules, "jsx-pascal-case": jsxPascalCase } } },
7
6
 
8
7
  rules: {
9
- /**
10
- * Enforce spacing inside array brackets 🔧
11
- * https://eslint.style/rules/array-bracket-spacing.
12
- */
13
- "style/array-bracket-spacing": ["error", "never"],
14
-
15
8
  /**
16
9
  * Require parens in arrow function arguments 🔧
17
10
  * https://eslint.style/rules/arrow-parens.
@@ -108,12 +101,6 @@ export default {
108
101
  */
109
102
  "style/function-call-spacing": ["error", "never"],
110
103
 
111
- /**
112
- * Enforce line breaks between arguments of a function call 🔧
113
- * https://eslint.style/rules/function-call-argument-newline.
114
- */
115
- "style/function-call-argument-newline": ["error", "consistent"],
116
-
117
104
  /**
118
105
  * Enforce the spacing around the * in generator functions 🔧
119
106
  * https://eslint.style/rules/generator-star-spacing.
@@ -214,30 +201,26 @@ export default {
214
201
  * Enforce whitespace in and around the JSX opening and closing brackets 🔧
215
202
  * https://eslint.style/rules/jsx-tag-spacing
216
203
  */
217
- "style/jsx-tag-spacing": ["error",
218
- {
219
- closingSlash: "never",
220
- beforeSelfClosing: "always",
221
- afterOpening: "never",
222
- beforeClosing: "never",
223
- },
224
- ],
204
+ "style/jsx-tag-spacing": ["error", {
205
+ closingSlash: "never",
206
+ beforeSelfClosing: "always",
207
+ afterOpening: "never",
208
+ beforeClosing: "never",
209
+ }],
225
210
 
226
211
  /**
227
212
  * Disallow missing parentheses around multiline JSX 🔧
228
213
  * https://eslint.style/rules/jsx-wrap-multilines
229
214
  */
230
- "style/jsx-wrap-multilines": ["error",
231
- {
232
- declaration: "parens-new-line",
233
- assignment: "parens-new-line",
234
- return: "parens-new-line",
235
- arrow: "parens-new-line",
236
- condition: "ignore",
237
- logical: "ignore",
238
- prop: "ignore",
239
- },
240
- ],
215
+ "style/jsx-wrap-multilines": ["error", {
216
+ declaration: "parens-new-line",
217
+ assignment: "parens-new-line",
218
+ return: "parens-new-line",
219
+ arrow: "parens-new-line",
220
+ condition: "ignore",
221
+ logical: "ignore",
222
+ prop: "ignore",
223
+ }],
241
224
 
242
225
  /**
243
226
  * Enforces spacing between keys and values in object literal properties 🔧
@@ -399,32 +382,6 @@ export default {
399
382
  */
400
383
  "style/one-var-declaration-per-line": ["error", "always"],
401
384
 
402
- /**
403
- * Enforce line breaks between braces. 🔧
404
- * https://eslint.style/rules/object-curly-newline.
405
- */
406
- "style/object-curly-newline": [
407
- "error",
408
- {
409
- ObjectExpression: { minProperties: 10, multiline: true, consistent: true },
410
- ObjectPattern: { minProperties: 10, multiline: true, consistent: true },
411
- ImportDeclaration: { minProperties: 10, multiline: true, consistent: true },
412
- ExportDeclaration: { minProperties: 10, multiline: true, consistent: true },
413
- },
414
- ],
415
-
416
- /**
417
- * Require padding inside curly braces 🔧
418
- * https://eslint.style/rules/object-curly-spacing.
419
- */
420
- "style/object-curly-spacing": ["error", "always"],
421
-
422
- /**
423
- * Enforce "same line" or "multiple line" on object properties. 🔧
424
- * https://eslint.style/rules/object-property-newline.
425
- */
426
- "style/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
427
-
428
385
  /**
429
386
  * Requires operator at the beginning of the line in multiline statements 🔧
430
387
  * https://eslint.style/rules/operator-linebreak.
@@ -554,7 +511,7 @@ export default {
554
511
  * Require consistent spacing around type annotations 🔧
555
512
  * https://eslint.style/rules/type-annotation-spacing
556
513
  */
557
- "style/type-annotation-spacing": "off",
514
+ "style/type-annotation-spacing": "error",
558
515
 
559
516
  /**
560
517
  * Enforces consistent spacing inside TypeScript type generics 🔧
@@ -586,5 +543,24 @@ export default {
586
543
  * https://eslint.style/rules/yield-star-spacing.
587
544
  */
588
545
  "style/yield-star-spacing": ["error", "after"],
546
+
547
+ /**
548
+ * Enforce consistent spacing and line break styles inside brackets. 🔧
549
+ * https://eslint.style/rules/list-style.
550
+ */
551
+ "style/list-style": ["error", {
552
+ empty: "ignore",
553
+ singleLine: { spacing: "never", maxItems: 25 },
554
+ overrides: {
555
+ "{}": { singleLine: { spacing: "always", maxItems: 9 } },
556
+ "CallExpression": "off",
557
+ "NewExpression": "off",
558
+ },
559
+ }],
560
+
561
+ /**
562
+ * Enforce consistent Pascal case on jsx elements.
563
+ */
564
+ "style/jsx-pascal-case": "error",
589
565
  },
590
566
  };
@@ -0,0 +1,16 @@
1
+ import typeormSecurityPlugin from "eslint-plugin-typeorm-security";
2
+
3
+ export default {
4
+ /*
5
+ * ✅ recommended
6
+ * 🔒 strict
7
+ * 🔧 fixable
8
+ * 💡 has suggestion
9
+ * 💭 requires type information
10
+ */
11
+ plugins: {
12
+ "typeorm-security": typeormSecurityPlugin,
13
+ },
14
+
15
+ rules: typeormSecurityPlugin.configs.recommended.rules,
16
+ };
@@ -554,16 +554,14 @@ export default {
554
554
  * Enforce template literal expressions to be of string type ✅ 💭
555
555
  * https://typescript-eslint.io/rules/.
556
556
  */
557
- "typescript/restrict-template-expressions": ["error",
558
- {
559
- allow: [{ name: ["Error", "URL", "URLSearchParams"], from: "lib" }],
560
- allowAny: true,
561
- allowBoolean: true,
562
- allowNullish: true,
563
- allowNumber: true,
564
- allowRegExp: true,
565
- },
566
- ],
557
+ "typescript/restrict-template-expressions": ["error", {
558
+ allow: [{ name: ["Error", "URL", "URLSearchParams"], from: "lib" }],
559
+ allowAny: true,
560
+ allowBoolean: true,
561
+ allowNullish: true,
562
+ allowNumber: true,
563
+ allowRegExp: true,
564
+ }],
567
565
 
568
566
  /**
569
567
  * Require switch-case statements to be exhaustive with union type 💡 💭
File without changes