eslint-config-beslogic 1.4.21 → 1.4.24

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/.eslintrc.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
5
6
  "root": true,
6
7
  "plugins": ["eslint-plugin"],
@@ -4,7 +4,6 @@
4
4
  // Please keep in alphabetical order
5
5
  {
6
6
  // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
7
- // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
8
7
  // List of extensions which should be recommended for users of this workspace.
9
8
  // Only keep those used by your specific project
10
9
  "recommendations": [
@@ -12,30 +11,31 @@
12
11
  "davidanson.vscode-markdownlint",
13
12
  "dbaeumer.vscode-eslint",
14
13
  "dprint.dprint",
15
- "dotenv.dotenv-vscode",
14
+ // "dotenv.dotenv-vscode",
16
15
  "eamodio.gitlens",
17
- "firsttris.vscode-jest-runner",
16
+ // "firsttris.vscode-jest-runner",
18
17
  // "johnpapa.angular2",
19
18
  "meganrogge.template-string-converter",
20
- "ms-vscode.vscode-typescript-next",
21
19
  "pkief.material-icon-theme"
20
+ // "redhat.vscode-xml",
21
+ // "redhat.vscode-yaml"
22
22
  ],
23
23
  // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
24
+ // Developpers should uninstall or disable the following extensions for this workspace
25
+ // https://github.com/microsoft/vscode/issues/40239
24
26
  "unwantedRecommendations": [
25
- // VSCode has implemented an optimized version
26
- "coenraads.bracket-pair-colorizer-2",
27
- // Lots of conflicts
28
- "esbenp.prettier-vscode",
29
- // Use workspace version instead
30
- "ms-vscode.vscode-typescript-next",
31
- // jest-runner is preferable and doesn't have issues with parametrized tests
32
- "orta.vscode-jest",
33
- // The ESLint plugin is sufficient in JS/TS projects
34
- "sonarsource.sonarlint-vscode",
35
- // Everything below is Deprecated or obsoleted
27
+ "dotjoshjohnson.xml", // Prevent VSCode from recommending a different XML extension than the one we recommend
28
+ "esbenp.prettier-vscode", // Lots of conflicts
29
+ "ms-vscode.vscode-typescript-next", // Use workspace version instead
30
+ "mikestead.dotenv", // Use the official plugin instead
31
+ "orta.vscode-jest", // firsttris.vscode-jest-runner is preferable and doesn't have issues with parametrized tests
32
+ "rvest.vs-code-prettier-eslint", // Lots of conflicts
33
+ "sonarsource.sonarlint-vscode", // Not project-configurable. And the ESLint plugin is sufficient in JS/TS projects
34
+ // Everything below is Deprecated
36
35
  "coenraads.bracket-pair-colorizer",
36
+ "coenraads.bracket-pair-colorizer-2",
37
37
  "eg2.tslint",
38
- "mikestead.dotenv",
39
- "ms-vscode.vscode-typescript-tslint-plugin"
38
+ "ms-vscode.vscode-typescript-tslint-plugin",
39
+ "simonsiefke.prettier-vscode"
40
40
  ]
41
41
  }
@@ -4,8 +4,7 @@
4
4
  {
5
5
  "files.associations": {
6
6
  ".eslintrc*.json": "jsonc",
7
- "dprint*.json": "jsonc",
8
- "tsconfig*.json": "jsonc"
7
+ "dprint*.json": "jsonc"
9
8
  },
10
9
  "editor.rulers": [
11
10
  80,
@@ -39,6 +38,7 @@
39
38
  // },
40
39
  "editor.codeActionsOnSave": {
41
40
  "source.fixAll": true,
41
+ // Let dedicated imports tool deal with it
42
42
  "source.organizeImports": false
43
43
  },
44
44
  "typescript.tsdk": "node_modules/typescript/lib",
@@ -66,6 +66,11 @@
66
66
  "mode": "auto"
67
67
  }
68
68
  ],
69
+ "eslint.codeActionsOnSave.rules": [
70
+ // Clearing imports because of commented code while testing is annoying
71
+ "!unused-imports/no-unused-imports",
72
+ "*"
73
+ ],
69
74
  "eslint.rules.customizations": [
70
75
  {
71
76
  "rule": "*",
@@ -95,5 +100,7 @@
95
100
  "package-lock.json": true,
96
101
  "*.lock": true
97
102
  },
98
- "editor.bracketPairColorization.enabled": true
103
+ "editor.bracketPairColorization.enabled": true,
104
+ "xml.codeLens.enabled": true,
105
+ "xml.format.maxLineWidth": 120
99
106
  }
package/README.md CHANGED
@@ -13,6 +13,16 @@ A [dprint preset](#beslogicdprint) is ofered below.
13
13
 
14
14
  ## Parallel configurations
15
15
 
16
+ Add the following scripts to your `package.json`:
17
+
18
+ ```json
19
+ "scripts": {
20
+ "eslint": "eslint ./ --ignore-path .gitignore",
21
+ "lint": "dprint check && npm run eslint",
22
+ "lint:fix": "dprint fmt && npm run eslint -- --fix",
23
+ }
24
+ ```
25
+
16
26
  These are configuration files you'll have to update manually to best work with these presets.
17
27
 
18
28
  - [VSCode Settings and Extensions](https://socket.dev/npm/package/eslint-config-beslogic/files/latest/.vscode)
@@ -38,13 +48,13 @@ Default preset, extends from `beslogic/javascript` and `beslogic/typescript`.
38
48
 
39
49
  ### `beslogic/javascript`
40
50
 
41
- Basic javascript configs, is extended by all other configs except `beslogic/typescript` and `beslogic/json-like`.
51
+ Basic javascript configs, is extended by all other configs except `beslogic/typescript`, `beslogic/jest`, `beslogic/storybook` and `beslogic/json-like`.
42
52
 
43
53
  ### `beslogic/typescript`
44
54
 
45
- Basic TypeScript-specific configs and `TSX` support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does **not** already extend from `beslogic/javascript`. So you should extend from both in a pure TypeScript project. You may also need to specify `parserOptions.project`. ie: `"parserOptions": { "project": ["tsconfig.json"] },` and `"parser": "@typescript-eslint/parser"`
55
+ Basic TypeScript-specific configs and `TSX` support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does **not** already extend from `beslogic/javascript`. So you should extend from both in a pure TypeScript project. You may also need to specify `parserOptions.project`. ie: `"parserOptions": { "project": ["tsconfig.json"] },` and `"parser": "@typescript-eslint/parser"`.
46
56
 
47
- For the linting to be fully effective, please make sure to set the following in your `tsconfig.json`:
57
+ For the linting to be fully effective, please make sure to set the following in your base `tsconfig.json`:
48
58
 
49
59
  <!-- dprint-ignore -->
50
60
  ```json
@@ -145,10 +155,13 @@ Add the following `devDependencies` to your `package.json`:
145
155
 
146
156
  Configurations for NGX projects. Comes with `html` template and inline template support. Already extends `beslogic/rxjs` and `beslogic/typescript`. Also extends `beslogic/node-js` for Javascript files.
147
157
 
148
- For the linting to be fully effective, please make sure to set the following in your `tsconfig.json`:
158
+ For the linting to be fully effective, please make sure to set the following in your base `tsconfig.json`:
149
159
 
150
160
  <!-- dprint-ignore -->
151
161
  ```jsonc
162
+ "compilerOptions": {
163
+ "emitDecoratorMetadata": true,
164
+ },
152
165
  "angularCompilerOptions": {
153
166
  // "strictMetadataEmit": true, // For bundling with an npm package
154
167
  "strictInjectionParameters": true,
package/angular.js CHANGED
@@ -53,6 +53,8 @@ const baseIgnoreAttributes = [
53
53
  "width",
54
54
  "xmlns"
55
55
  ]
56
+
57
+ /** @type {import("eslint").Linter.Config} */
56
58
  module.exports = {
57
59
  "overrides": [
58
60
  {
@@ -81,9 +83,14 @@ module.exports = {
81
83
  "allowNullOrUndefined": true
82
84
  }
83
85
  ],
86
+ // autofix for this rule is broken: https://github.com/angular-eslint/angular-eslint/issues/1197
87
+ "@angular-eslint/template/attributes-order": "off",
88
+ // and it was added in 14.2.0. Not enforcing it for now allows a wider range of versions
89
+ "no-autofix/@angular-eslint/template/attributes-order": "off",
84
90
  "@angular-eslint/template/i18n": "off",
85
91
  "no-autofix/@angular-eslint/template/i18n": [
86
- "error",
92
+ // Too many TODO and needs per-project extensions to justify this as "error"
93
+ "warn",
87
94
  {
88
95
  // TODO: doesn't work for text elements.
89
96
  // see: https://github.com/angular-eslint/angular-eslint/issues/999
@@ -129,11 +136,10 @@ module.exports = {
129
136
  ],
130
137
  "parserOptions": {
131
138
  "project": [
132
- "tsconfig.json",
133
- "tsconfig.*.json",
134
- "projects/*/tsconfig.*.json",
139
+ "tsconfig?(.*).json",
140
+ "projects/*/tsconfig?(.*).json",
135
141
  // eslint-disable-next-line etc/no-commented-out-code
136
- "*/tsconfig.json" // e2e/tsconfig.json
142
+ "*/tsconfig?(.*).json" // e2e/tsconfig.json
137
143
  ],
138
144
  // TODO: Consider use a tsconfig.eslint.json instead
139
145
  // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionscreatedefaultprogram
@@ -192,10 +198,6 @@ module.exports = {
192
198
  }
193
199
  }
194
200
  ],
195
- "@typescript-eslint/semi": [
196
- "error",
197
- "always"
198
- ],
199
201
  // Angular directives can lead to empty classes
200
202
  "@typescript-eslint/no-extraneous-class": [
201
203
  "error",
package/dprint-base.json CHANGED
@@ -8,15 +8,16 @@
8
8
  // "quoteStyle": "alwaysDouble", // If using beslogic/json-like
9
9
  "quoteProps": "asNeeded", // If NOT using beslogic/json-like
10
10
  // "quoteProps": "preserve", // If using beslogic/json-like
11
+ // "trailingCommas": "never", // If using beslogic/json-like
11
12
  "newLineKind": "auto",
12
- "semiColons": "asi", // Except for angular
13
+ "semiColons": "asi",
13
14
  "operatorPosition": "sameLine",
14
15
  "conditionalExpression.operatorPosition": "nextLine",
15
16
  "arrowFunction.useParentheses": "preferNone",
16
17
  "binaryExpression.linePerExpression": true,
17
18
  // Not convinced yet
18
19
  // "memberExpression.linePerExpression": true,
19
- "typeLiteral.separatorKind": "comma", // Except for angular
20
+ "typeLiteral.separatorKind": "comma",
20
21
  "enumDeclaration.memberSpacing": "newLine",
21
22
  "importDeclaration.forceSingleLine": true,
22
23
  // conflicts with simple-import-sort/imports
package/dprint.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
4
  /* eslint-disable etc/no-commented-out-code */
5
+ /** @type {import("eslint").Linter.Config} */
5
6
  module.exports = {
6
7
  "overrides": [
7
8
  {
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
5
6
  "extends": [
6
7
  "./javascript",
package/javascript.js CHANGED
@@ -31,6 +31,7 @@ const idLenghtConfig = {
31
31
  ]
32
32
  }
33
33
 
34
+ /** @type {import("eslint").Linter.Config} */
34
35
  module.exports = {
35
36
  "plugins": [
36
37
  "extra-rules",
@@ -85,6 +86,11 @@ module.exports = {
85
86
  ".test.jsx"
86
87
  ],
87
88
  "extends": ["./jest"]
89
+ },
90
+ {
91
+ "files": [".eslintrc.js"],
92
+ "globals": { "module": true },
93
+ "extends": ["./json-like"]
88
94
  }
89
95
  ],
90
96
  "rules": {
@@ -94,8 +100,8 @@ module.exports = {
94
100
  // unused-imports settings
95
101
  // Loosing imports when commenting to test is extremely annoying and slow,
96
102
  // so we only use this rule when ran from the command-line
97
- // no-autofix/unused-imports is redundant with no-unused-vars
98
- "unused-imports/no-unused-imports": "off",
103
+ // no-autofix/unused-imports is redundant with no-unused-vars and and eslint.codeActionsOnSave.rules
104
+ "unused-imports/no-unused-imports": "warn",
99
105
 
100
106
  // unicorn/all overrides (https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
101
107
  "unicorn/catch-error-name": [
package/jest.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
5
6
  "extends": [
6
7
  "plugin:jest/all",
@@ -12,6 +13,13 @@ module.exports = {
12
13
  "jest": true,
13
14
  "jest/globals": true
14
15
  },
16
+ "overrides": [
17
+ {
18
+ "files": [".eslintrc.js"],
19
+ "globals": { "module": true },
20
+ "extends": ["./json-like"]
21
+ }
22
+ ],
15
23
  "rules": {
16
24
  // Using only max-lines and not max-lines-per-function as most of the jest code lives in functions.
17
25
  "max-lines-per-function": "off",
package/json-like.js CHANGED
@@ -1,7 +1,14 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
6
+ "overrides": [
7
+ {
8
+ "files": [".eslintrc.js"],
9
+ "globals": { "module": true }
10
+ }
11
+ ],
5
12
  "rules": {
6
13
  "array-bracket-newline": [
7
14
  "error",
package/mui.js CHANGED
@@ -10,6 +10,7 @@ const noMagicNumbersConfig = typeScriptConfig.overrides[0].rules["@typescript-es
10
10
  if (typeof idLenghtConfig === "string") throw new TypeError("idLenghtConfig is a string")
11
11
  if (typeof noMagicNumbersConfig === "string") throw new TypeError("noMagicNumbersConfig is a string")
12
12
 
13
+ /** @type {import("eslint").Linter.Config} */
13
14
  module.exports = {
14
15
  "plugins": ["mui"],
15
16
  "extends": [
package/node-js.js CHANGED
@@ -15,6 +15,7 @@ preventAbbreviationsConfig.allowList.res = true
15
15
  preventAbbreviationsConfig.allowList.req = true
16
16
  const expressGlobalMessage = "Import from express instead."
17
17
 
18
+ /** @type {import("eslint").Linter.Config} */
18
19
  module.exports = {
19
20
  "extends": [
20
21
  "./javascript",
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "eslint-config-beslogic",
3
- "version": "1.4.21",
3
+ "version": "1.4.24",
4
4
  "description": "ESLint rules, plugins and configs used at Beslogic",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "eslint": "eslint ./ --ignore-path .gitignore --rule \"unused-imports/no-unused-imports:'error'\"",
7
+ "eslint": "eslint ./ --ignore-path .gitignore",
8
8
  "lint": "node ./node_modules/dprint/bin check && npm run eslint",
9
9
  "lint:fix": "node ./node_modules/dprint/bin fmt && npm run eslint -- --fix",
10
10
  "upgrade": "npx npm-check-updates -u & npm i",
11
- "yalc": "yalc publish",
12
- "prepack": "type .gitignore* > .npmignore"
11
+ "yalc": "yalc publish"
13
12
  },
14
13
  "keywords": [
15
14
  "eslint",
package/react-native.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
5
6
  "extends": ["./react"],
6
7
  "rules": {
package/react-redux.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
5
6
  "plugins": ["react-redux"],
6
7
  "extends": [
package/react.js CHANGED
@@ -17,6 +17,7 @@ preventAbbreviationsConfig.allowList.Props = true
17
17
  preventAbbreviationsConfig.allowList.ref = true
18
18
  preventAbbreviationsConfig.allowList.Ref = true
19
19
 
20
+ /** @type {import("eslint").Linter.Config} */
20
21
  module.exports = {
21
22
  "extends": [
22
23
  "./javascript",
package/rxjs.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2023 Beslogic Inc.
3
3
 
4
+ /** @type {import("eslint").Linter.Config} */
4
5
  module.exports = {
5
6
  "extends": [
6
7
  "./javascript",
package/storybook.js CHANGED
@@ -5,6 +5,7 @@ const angularConfig = require("./angular")
5
5
 
6
6
  const noRestrictedSyntax = { ...angularConfig.overrides[1].rules["no-restricted-syntax"] }
7
7
 
8
+ /** @type {import("eslint").Linter.Config} */
8
9
  module.exports = {
9
10
  "extends": [
10
11
  "plugin:storybook/recommended",
package/typescript.js CHANGED
@@ -24,6 +24,7 @@ const getModuleVersion = nodeModule =>
24
24
  // I already checked for dynamic rules up to v5.23.0
25
25
  const typescriptEslintVersion = getModuleVersion("@typescript-eslint/eslint-plugin")
26
26
 
27
+ /** @type {import("eslint").Linter.Config} */
27
28
  module.exports = {
28
29
  "overrides": [
29
30
  {
@@ -55,9 +56,8 @@ module.exports = {
55
56
  // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
56
57
  "alwaysTryTypes": true,
57
58
  "project": [
58
- "tsconfig.json",
59
- "tsconfig.*.json",
60
- "projects/*/tsconfig.*.json"
59
+ "tsconfig?(.*).json",
60
+ "projects/*/tsconfig?(.*).json"
61
61
  ]
62
62
  }
63
63
  }
@@ -70,7 +70,7 @@ module.exports = {
70
70
  },
71
71
  "parser": "@typescript-eslint/parser",
72
72
  "parserOptions": {
73
- "project": ["tsconfig.json"],
73
+ "project": ["tsconfig?(.*).json"],
74
74
  "sourceType": "module",
75
75
  "ecmaFeatures": {
76
76
  "impliedStrict": true
@@ -87,11 +87,12 @@ module.exports = {
87
87
  "unicode-bom": "off",
88
88
 
89
89
  // eslint-plugin-total-functions overrides (https://www.npmjs.com/package/eslint-plugin-total-functions#user-content-rules)
90
- // It takes an advanced TypeScript use to fully make sense of this rule
90
+ // It takes an advanced TypeScript user to fully make sense of this rule
91
91
  /**
92
+ * (copied from https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Templates/_wiki/wikis/Beslogic-Architecture-Templates.wiki/656/Frontend-linting-and-formatting?anchor=total-functions/no-unsafe-type-assertion)
92
93
  * It can sometimes be hard to make sense of this rule, but let's be strict!
93
94
  * Tips:
94
- * - Try to assign to an explicitely typed variable and TypeScript will tell you abou the type difference!
95
+ * - Try to assign to an explicitely typed variable and TypeScript will tell you about the type difference!
95
96
  * ie: `const newValue: ExpectedType = unsafeValue`
96
97
  * - Prefer coersion over assertion: `String(value ?? '')` over `value as string | null`
97
98
  * - Sometimes just casting as `Partial<>` is sufficient
@@ -1,2 +0,0 @@
1
- # .npmignore
2
- *.ini