eslint-config-beslogic 2.3.1 → 2.4.5

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.
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
- // Keep in sync with https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Templates/_wiki/wikis/Beslogic-Architecture-Templates.wiki/757/VSCode-settings-and-extensions-(.vscode-.code-workspace)
3
+ // Keep in sync with https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Reference/_wiki/wikis/Beslogic-Architecture-Reference.wiki/757/VSCode-settings-and-extensions-(.vscode-.code-workspace)
4
4
  //
5
5
  // Please keep in alphabetical order
6
6
  {
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
- // Keep in sync with https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Templates/_wiki/wikis/Beslogic-Architecture-Templates.wiki/757/VSCode-settings-and-extensions-(.vscode-.code-workspace)
3
+ // Keep in sync with https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Reference/_wiki/wikis/Beslogic-Architecture-Reference.wiki/757/VSCode-settings-and-extensions-(.vscode-.code-workspace)
4
4
 
5
5
  {
6
6
  "files.associations": {
package/CHANGELOG.md CHANGED
@@ -1,9 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.4.5
4
+
5
+ - Include documentation about usage with `.pre-commit-config.yaml`/`pre-commit.ci`
6
+ - Allow omitting `esling-plugin-no-autofix`, `eslint-plugin-jest`, `eslint-plugin-jest-formatting` and `eslint-plugin-etc` for `.pre-commit-config.yaml`/`pre-commit.ci`
7
+ - `pre-commit.ci` run will always assume the following are not installed to save on space:
8
+ - `eslint-plugin-total-functions`
9
+ - `esling-plugin-no-autofix`
10
+ - `eslint-plugin-testing-library`
11
+ - `eslint-plugin-jest-formatting`
12
+ - `eslint-plugin-jest`
13
+ - `eslint-plugin-etc`
14
+ - Moved `eslint-plugin-angular-file-naming` to `optionalDependencies`
15
+ - Moved `eslint-plugin-testing-library` to `dependencies`
16
+ - Bumped `eslint-plugin-unused-imports` to `^3.2.0` to fix error with `@typescript-eslint@7.8`
17
+ - Don't check for camelcase properties in eslint config files
18
+
19
+ ## 2.3.2
20
+
21
+ - Added "data-service", "interceptor" and "guard" as valid suffix for `angular-file-naming/service-filename-suffix`
22
+
3
23
  ## 2.3.1
4
24
 
5
- <!-- dprint-ignore -->
6
- - Fixed the following error when parsing `typescript`` config:\
25
+ - Fixed the following error when parsing `typescript` config:
7
26
  `Configuration for rule "@typescript-eslint/prefer-string-starts-ends-with" is invalid: Value true should be string.`
8
27
  - Added `no-restricted-syntax` rules to ensure that Angular optional dependencies are marked as optional in TypeScript and vice-versa
9
28
  - Fixed Storybook custom `.ts` configuration not being applied
@@ -29,7 +48,7 @@
29
48
  - Check context objects with `react/display-name`
30
49
  - Added React 18 deprecations
31
50
  - Remove accidental recommendation to install `eslint-plugn-react-redux` from non-redux presets in `README.md`
32
- - Now enforce at least 1 newline after imports even with dprint preset.
51
+ - Now enforce at least 1 newline after imports even with dprint preset
33
52
  - Turn on `allowImplicit`, `checkForEach`, and `allowVoid` for rule `array-callback-return`
34
53
  - Bumped `eslint-plugin-total-functions` to `>=6.0`
35
54
  - which bumps `typescript` dependency to `4.7.3`
package/README.md CHANGED
@@ -51,7 +51,7 @@ If deploying / bundling with an Angular npm package, also set `angularCompilerOp
51
51
 
52
52
  ### `.vscode/settings.json` and `.vscode/extensions.json`
53
53
 
54
- <!-- Keep in sync with https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Templates/_wiki/wikis/Beslogic-Architecture-Templates.wiki/757/VSCode-settings-and-extensions-(.vscode-.code-workspace) -->
54
+ <!-- Keep in sync with https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Reference/_wiki/wikis/Beslogic-Architecture-Reference.wiki/757/VSCode-settings-and-extensions-(.vscode-.code-workspace) -->
55
55
 
56
56
  Read and copy from [VSCode Settings and Extensions](https://socket.dev/npm/package/eslint-config-beslogic/files/latest/.vscode)
57
57
 
@@ -73,6 +73,24 @@ If you'd like to pin your config version, you can use a commit hash, like `https
73
73
 
74
74
  If also using [`beslogic/json-like` preset](#beslogicjson-like) extend from `https://raw.githubusercontent.com/BesLogic/shared-configs/main/dprint-json-like.json` instead.
75
75
 
76
+ ### Usage with `pre-commit.ci` (`.pre-commit-config.yaml`)
77
+
78
+ Use the following hook: <https://github.com/pre-commit/mirrors-eslint>
79
+
80
+ Set `args: [--fix, --quiet]`.
81
+
82
+ In the `additional_dependencies` field, you'll need to include _all_ the plugins we use (copy this project's `dependencies` in `package.json`), as well as the optional plugins you need for yor presets.
83
+
84
+ As you'll easily bust the 250MiB limit on the free tier, omit the following dependencies as they're special-cased to always be ignored on `pre-commit.ci` anyway:
85
+
86
+ - `dprint`
87
+ - `eslint-plugin-total-functions`
88
+ - `esling-plugin-no-autofix`
89
+ - `eslint-plugin-testing-library`
90
+ - `eslint-plugin-jest-formatting`
91
+ - `eslint-plugin-jest`
92
+ - `eslint-plugin-etc`
93
+
76
94
  ## Patched packages
77
95
 
78
96
  The following packages cause problems or have other type-safety issues that are automatically patched out by `eslint-config-beslogic` on install. To see the complete logs, add `foreground-scripts=true` to a root `.npmrc` file, or run `npm install` with `--foreground-scripts`.
package/angular.js CHANGED
@@ -1,10 +1,16 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
3
 
4
- const { getModuleVersion, jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
4
+ const { getModuleVersion, jestNoRestrictedSyntax, jestFilePatterns, resolveModuleLocation } =
5
+ require("./lib/utils")
5
6
 
6
7
  const angularEslintVersion = getModuleVersion("@angular-eslint/eslint-plugin", 16.2)
7
8
  const typescriptVersion = getModuleVersion("typescript", 4.7)
9
+ const hasTestingLibrary = !!resolveModuleLocation("eslint-plugin-testing-library")
10
+ // eslint-plugin-no-autofix is broken when run through pre-commit
11
+ // https://github.com/aladdin-add/eslint-plugin/issues/98
12
+ // Even if it gets fixed, `no-autofix` rules necessarily don't provide fixes anyway
13
+ const hasNoAutofix = !!resolveModuleLocation("eslint-plugin-no-autofix")
8
14
 
9
15
  const javascriptConfig = require("./javascript")
10
16
  const typescriptConfig = require("./typescript")
@@ -71,7 +77,7 @@ module.exports = {
71
77
  "overrides": [
72
78
  {
73
79
  "files": ["*.html"],
74
- "plugins": ["no-autofix"],
80
+ "plugins": hasNoAutofix ? ["no-autofix"] : [],
75
81
  "extends": ["plugin:@angular-eslint/template/all"],
76
82
  "rules": {
77
83
  "@angular-eslint/template/click-events-have-key-events": "off",
@@ -113,7 +119,9 @@ module.exports = {
113
119
  "@angular-eslint/template/i18n": "off",
114
120
  "no-autofix/@angular-eslint/template/i18n": [
115
121
  // Too many TODO and needs per-project extensions to justify this as "error"
116
- "warn",
122
+ hasNoAutofix
123
+ ? "warn"
124
+ : "off",
117
125
  {
118
126
  // NOTE: doesn't work for text elements.
119
127
  // See: https://github.com/angular-eslint/angular-eslint/issues/999
@@ -202,7 +210,17 @@ module.exports = {
202
210
  "angular-file-naming/directive-filename-suffix": "error",
203
211
  "angular-file-naming/module-filename-suffix": "error",
204
212
  "angular-file-naming/pipe-filename-suffix": "error",
205
- "angular-file-naming/service-filename-suffix": "error",
213
+ "angular-file-naming/service-filename-suffix": [
214
+ "error",
215
+ {
216
+ "suffixes": [
217
+ "service",
218
+ "data-service",
219
+ "interceptor",
220
+ "guard"
221
+ ]
222
+ }
223
+ ],
206
224
 
207
225
  /*
208
226
  * rxjs-angular rules
@@ -353,7 +371,9 @@ module.exports = {
353
371
  },
354
372
  {
355
373
  "files": jestFilePatterns,
356
- "extends": ["plugin:testing-library/angular"],
374
+ "extends": hasTestingLibrary
375
+ ? ["plugin:testing-library/angular"]
376
+ : [],
357
377
  "rules": { "no-restricted-syntax": jestNoRestrictedSyntax(noRestrictedSyntax) }
358
378
  },
359
379
  {
package/javascript.js CHANGED
@@ -2,36 +2,20 @@
2
2
  // Copyright 2024 Beslogic Inc.
3
3
 
4
4
  const restrictedGlobals = require("confusing-browser-globals")
5
- const { jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
5
+ const { jestNoRestrictedSyntax, jestFilePatterns, resolveModuleLocation, idLenghtConfig } = require(
6
+ "./lib/utils"
7
+ )
8
+
9
+ // The only autofix we use is `no-implicit-any-catch` and this is a big module for pre-commit
10
+ // Outside of pre-commit, `eslint-plugin-etc` should NOT be considered optional !
11
+ const hasEtc = !!resolveModuleLocation("eslint-plugin-etc")
12
+ // eslint-plugin-no-autofix is broken when run through pre-commit
13
+ // https://github.com/aladdin-add/eslint-plugin/issues/98
14
+ // Even if it gets fixed, `no-autofix` rules necessarily don't provide fixes anyway
15
+ const hasNoAutofix = !!resolveModuleLocation("eslint-plugin-no-autofix")
6
16
 
7
17
  const commaDangleDefault = "always-multiline"
8
- const idLenghtConfig = {
9
- "min": 3,
10
- "max": 32,
11
- "properties": "never",
12
- "exceptionPatterns": [
13
- // Unused result
14
- "__?",
15
- // Comparison and Iterations
16
- "[a-bi-k]"
17
- ],
18
- "exceptions": [
19
- "id",
20
- "fn",
21
- "to",
22
- "TO",
23
- // Matches
24
- "or",
25
- "OR",
26
- "on",
27
- // Date formats
28
- "dd",
29
- "mm",
30
- "yy",
31
- // HTTP status codes
32
- "OK"
33
- ]
34
- }
18
+
35
19
  const noRestrictedSyntax = [
36
20
  "error",
37
21
  "WithStatement",
@@ -60,12 +44,14 @@ const noRestrictedSyntax = [
60
44
  module.exports = {
61
45
  "plugins": [
62
46
  "extra-rules",
63
- "no-autofix",
47
+ ...hasNoAutofix ? ["no-autofix"] : [],
64
48
  "prefer-arrow",
65
49
  "simple-import-sort",
66
50
  "no-relative-import-paths",
67
51
  "unused-imports",
68
- "etc"
52
+ ...hasEtc
53
+ ? ["etc"]
54
+ : []
69
55
  ],
70
56
  "extends": [
71
57
  "eslint:recommended",
@@ -345,7 +331,9 @@ module.exports = {
345
331
  ],
346
332
  // Using this to completely disallow all console calls except info, warn, error
347
333
  "no-autofix/no-console": [
348
- "error",
334
+ hasNoAutofix
335
+ ? "error"
336
+ : "off",
349
337
  {
350
338
  "allow": [
351
339
  "info",
@@ -394,6 +382,11 @@ module.exports = {
394
382
  // "extends": ["./json-like"]
395
383
  "globals": { "module": true },
396
384
  "rules": {
385
+ // We don't have control on keys names
386
+ "camelcase": [
387
+ "error",
388
+ { "properties": "never" }
389
+ ],
397
390
  // Keep consistent with preset rules
398
391
  "unicorn/prefer-string-raw": "off"
399
392
  }
@@ -452,7 +445,9 @@ module.exports = {
452
445
 
453
446
  // Extracted restricted import into its own rule so it's easier for projects to override/ignore
454
447
  "no-autofix/no-relative-import-paths/no-relative-import-paths": [
455
- "error",
448
+ hasNoAutofix
449
+ ? "error"
450
+ : "off",
456
451
  {
457
452
  "allowSameFolder": true
458
453
  }
@@ -464,7 +459,9 @@ module.exports = {
464
459
  // Loosing imports when commenting to test is extremely annoying and slow,
465
460
  // so we only use this rule when ran from the command-line
466
461
  // no-autofix/unused-imports/no-unused-imports is redundant with no-unused-vars and and eslint.codeActionsOnSave.rules
467
- "unused-imports/no-unused-imports": "warn",
462
+ "unused-imports/no-unused-imports": hasNoAutofix
463
+ ? "warn"
464
+ : "off",
468
465
 
469
466
  // unicorn/all overrides (https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
470
467
  "unicorn/catch-error-name": [
@@ -569,7 +566,9 @@ module.exports = {
569
566
  /*
570
567
  * Cartant's etc rules
571
568
  */
572
- "etc/no-commented-out-code": "error",
569
+ "etc/no-commented-out-code": hasEtc
570
+ ? "error"
571
+ : "off",
573
572
 
574
573
  /*
575
574
  * Simple import rules
@@ -599,12 +598,25 @@ module.exports = {
599
598
  /*
600
599
  * Prefer Arrow rule
601
600
  */
601
+ // Autofixing is only applied when only checking for `singleReturnOnly: true`
602
+ // but we still want to check for other cases
603
+ "no-autofix/prefer-arrow/prefer-arrow-functions": [
604
+ hasNoAutofix
605
+ ? "error"
606
+ : "off",
607
+ {
608
+ "classPropertiesAllowed": true,
609
+ "disallowPrototype": true,
610
+ "singleReturnOnly": false,
611
+ "allowStandaloneDeclarations": false
612
+ }
613
+ ],
602
614
  "prefer-arrow/prefer-arrow-functions": [
603
615
  "error",
604
616
  {
605
617
  "classPropertiesAllowed": true,
606
618
  "disallowPrototype": true,
607
- "singleReturnOnly": false,
619
+ "singleReturnOnly": true,
608
620
  "allowStandaloneDeclarations": false
609
621
  }
610
622
  ],
@@ -668,7 +680,9 @@ module.exports = {
668
680
  // HACK: Workaround for coordinates objects
669
681
  // TODO: Should be using rule composition instead
670
682
  "no-autofix/id-length": [
671
- "error",
683
+ hasNoAutofix
684
+ ? "error"
685
+ : "off",
672
686
  idLenghtConfig
673
687
  ],
674
688
  "id-length": [
package/jest.js CHANGED
@@ -1,22 +1,38 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
- const { getModuleVersion } = require("./lib/utils")
3
+ const { getModuleVersion, resolveModuleLocation } = require("./lib/utils")
4
4
 
5
5
  const jestGlobalsVersion = getModuleVersion("@jest/globals", 29)
6
+ // These are big modules for pre-commit.
7
+ // Outside of pre-commit, these should NOT be considered optional !
8
+ const hasTestingLibrary = !!resolveModuleLocation("eslint-plugin-testing-library")
9
+ const hasJestFormatting = !!resolveModuleLocation("eslint-plugin-jest-formatting")
10
+ const hasJest = !!resolveModuleLocation("eslint-plugin-jest")
6
11
 
7
12
  /** @type {import("eslint").Linter.Config} */
8
13
  module.exports = {
9
14
  "extends": [
10
- "plugin:jest/all",
11
- "plugin:jest-formatting/strict",
15
+ ...hasJest
16
+ ? ["plugin:jest/all"]
17
+ : [],
18
+ ...hasJestFormatting
19
+ ? ["plugin:jest-formatting/strict"]
20
+ : [],
12
21
  // Note: The DOM preset includes some rules not in Marko or Vue (eg.: no-await-sync-events).
13
22
  // Those must be disabled in their preset if we ever support them.
14
- "plugin:testing-library/dom"
23
+ ...hasTestingLibrary
24
+ ? ["plugin:testing-library/dom"]
25
+ : []
15
26
  ],
16
27
  "env": {
17
28
  "browser": false,
18
29
  "jest": true,
19
- "jest/globals": true
30
+ ...hasJest
31
+ ? {
32
+ // Setting to `false` is not enough: Environment key "jest/globals" is unknown
33
+ "jest/globals": true
34
+ }
35
+ : {}
20
36
  },
21
37
  "overrides": [
22
38
  {
@@ -62,40 +78,52 @@ module.exports = {
62
78
  "error",
63
79
  { "threshold": 8 }
64
80
  ],
65
- // Doesn't print well with testing-library's `findBy` and `waitFor`
66
- "jest/prefer-expect-resolves": "off",
67
- // May lead to accidentally missed expects
68
- "jest/prefer-expect-assertions": [
69
- "error",
70
- {
71
- "onlyFunctionsWithExpectInCallback": true,
72
- "onlyFunctionsWithExpectInLoop": true
73
- }
74
- ],
75
- // https://github.com/jestjs/jest/issues/15084
76
- // Since this will require a major jest version bump anyway,
77
- // I feel confortable not waiting for our own major version bump to add this
78
- ...(jestGlobalsVersion < 30
79
- ? { "jest/prefer-importing-jest-globals": "off" }
80
- : {}),
81
- // Top-level describe is often used for component name, which is capitalized
82
- "jest/prefer-lowercase-title": [
83
- "error",
84
- { "ignoreTopLevelDescribe": true }
85
- ],
86
- // Allow clearing mocks in beforeEach
87
- "jest/no-hooks": [
88
- "error",
89
- {
90
- "allow": ["beforeEach"]
81
+
82
+ /*
83
+ * jest/all overrides (https://github.com/jest-community/eslint-plugin-jest#rules)
84
+ */
85
+ ...hasJest
86
+ ? {
87
+ // Doesn't print well with testing-library's `findBy` and `waitFor`
88
+ "jest/prefer-expect-resolves": "off",
89
+ // May lead to accidentally missed expects
90
+ "jest/prefer-expect-assertions": [
91
+ "error",
92
+ {
93
+ "onlyFunctionsWithExpectInCallback": true,
94
+ "onlyFunctionsWithExpectInLoop": true
95
+ }
96
+ ],
97
+ // https://github.com/jestjs/jest/issues/15084
98
+ // Since this will require a major jest version bump anyway,
99
+ // I feel confortable not waiting for our own major version bump to add this
100
+ ...jestGlobalsVersion < 30
101
+ ? { "jest/prefer-importing-jest-globals": "off" }
102
+ : {},
103
+ // Top-level describe is often used for component name, which is capitalized
104
+ "jest/prefer-lowercase-title": [
105
+ "error",
106
+ { "ignoreTopLevelDescribe": true }
107
+ ],
108
+ // Allow clearing mocks in beforeEach
109
+ "jest/no-hooks": [
110
+ "error",
111
+ {
112
+ "allow": ["beforeEach"]
113
+ }
114
+ ]
91
115
  }
92
- ],
116
+ : {},
93
117
 
94
118
  /*
95
119
  * testing-library overrides (https://github.com/testing-library/eslint-plugin-testing-library#supported-rules)
96
120
  */
97
- "testing-library/no-debugging-utils": "error",
98
- "testing-library/prefer-user-event": "warn",
99
- "testing-library/prefer-explicit-assert": "error"
121
+ ...hasTestingLibrary
122
+ ? {
123
+ "testing-library/no-debugging-utils": "error",
124
+ "testing-library/prefer-user-event": "warn",
125
+ "testing-library/prefer-explicit-assert": "error"
126
+ }
127
+ : {}
100
128
  }
101
129
  }
package/lib/utils.js CHANGED
@@ -1,3 +1,7 @@
1
+ // const isPreCommitCI = __dirname.startsWith("/pc/clone/")
2
+ // console.log(__dirname)
3
+ // console.log(__filename)
4
+
1
5
  const getModuleVersion = (
2
6
  /** @type {string} */ nodeModule,
3
7
  /** @type {number} */ fallbackVersion
@@ -19,7 +23,16 @@ const getModuleVersion = (
19
23
 
20
24
  const resolveModuleLocation = (/** @type {string} */ nodeModule) => {
21
25
  try {
22
- return require.resolve(nodeModule)
26
+ // console.log(__dirname)
27
+ // console.log(__filename)
28
+ const resolved = require.resolve(nodeModule)
29
+ // DEBUG: console.log(resolved)
30
+ if (resolved.startsWith("/pc/clone/")) {
31
+ // Assume it's omitted from the pre-commit.ci run
32
+ return false
33
+ }
34
+
35
+ return resolved
23
36
  } catch {
24
37
  return false
25
38
  }
@@ -42,9 +55,39 @@ const jestFilePatterns = [
42
55
  "**/?(*.)+(spec|test).[jt]s?(x)"
43
56
  ]
44
57
 
58
+ const idLenghtConfig = {
59
+ "min": 3,
60
+ "max": 32,
61
+ "properties": "never",
62
+ "exceptionPatterns": [
63
+ // Unused result
64
+ "__?",
65
+ // Comparison and Iterations
66
+ "[a-bi-k]"
67
+ ],
68
+ "exceptions": [
69
+ "id",
70
+ "fn",
71
+ "to",
72
+ "TO",
73
+ // Matches
74
+ "or",
75
+ "OR",
76
+ "on",
77
+ // Date formats
78
+ "dd",
79
+ "mm",
80
+ "yy",
81
+ // HTTP status codes
82
+ "OK"
83
+ ]
84
+ }
85
+
45
86
  module.exports = {
46
87
  getModuleVersion,
88
+ idLenghtConfig,
89
+ // isPreCommitCI,
90
+ jestFilePatterns,
47
91
  jestNoRestrictedSyntax,
48
- resolveModuleLocation,
49
- jestFilePatterns
92
+ resolveModuleLocation
50
93
  }
package/mui.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
3
 
4
- const javascriptConfig = require("./javascript")
5
4
  const typeScriptConfig = require("./typescript")
5
+ const { idLenghtConfig } = require("./lib/utils")
6
6
 
7
- const idLenghtConfig = javascriptConfig.rules?.["no-autofix/id-length"]?.[1]
8
7
  const noMagicNumbersConfig = typeScriptConfig.overrides?.[0].rules
9
8
  ?.["@typescript-eslint/no-magic-numbers"]?.[1]
10
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-beslogic",
3
- "version": "2.3.1",
3
+ "version": "2.4.5",
4
4
  "description": "ESLint rules, plugins and configs used at Beslogic",
5
5
  "main": "index.js",
6
6
  "// dependencies": "Run for ourselves when we install dependencies w/o running npm i afterward",
@@ -47,7 +47,6 @@
47
47
  "dprint": "^0.40.2",
48
48
  "eslint": "^8.56",
49
49
  "eslint-import-resolver-typescript": "^3.2.6",
50
- "eslint-plugin-angular-file-naming": "^1.0.6",
51
50
  "eslint-plugin-autofix": "^1.1 || ^2.0",
52
51
  "eslint-plugin-etc": "^2.0",
53
52
  "eslint-plugin-extra-rules": "^0.0.0-development",
@@ -60,8 +59,9 @@
60
59
  "eslint-plugin-regexp": "^2.0",
61
60
  "eslint-plugin-simple-import-sort": ">=12.0",
62
61
  "eslint-plugin-sonarjs": "^1.0",
62
+ "eslint-plugin-testing-library": "^6.0",
63
63
  "eslint-plugin-unicorn": ">=49.0",
64
- "eslint-plugin-unused-imports": "^3.0"
64
+ "eslint-plugin-unused-imports": "^3.2"
65
65
  },
66
66
  "// eslint-plugin-total-functions": "Supported version is dictated by TypeScript and ESLint",
67
67
  "// (cont)": "Also made optional because of extra strictness",
@@ -69,6 +69,7 @@
69
69
  "@angular-eslint/eslint-plugin": ">=16.2",
70
70
  "@angular-eslint/eslint-plugin-template": ">=16.2",
71
71
  "@angular-eslint/template-parser": ">=16.2",
72
+ "eslint-plugin-angular-file-naming": "^1.0.6",
72
73
  "eslint-plugin-jsx-a11y": "^6.7.1",
73
74
  "eslint-plugin-mui": "^0.1.1",
74
75
  "eslint-plugin-n": ">=17.0",
@@ -79,7 +80,6 @@
79
80
  "eslint-plugin-rxjs": "^5.0.3",
80
81
  "eslint-plugin-rxjs-angular": "github:BesLogic/eslint-plugin-rxjs-angular#dist",
81
82
  "eslint-plugin-storybook": "^0.6.10",
82
- "eslint-plugin-testing-library": "^6.0",
83
83
  "eslint-plugin-total-functions": ">=6.0"
84
84
  },
85
85
  "// plugins": "Test against highest supported version to catch new breaking changes",
package/react.js CHANGED
@@ -3,6 +3,9 @@
3
3
 
4
4
  const javascriptConfig = require("./javascript")
5
5
  const typescriptConfig = require("./typescript")
6
+ const { jestFilePatterns, resolveModuleLocation } = require("./lib/utils")
7
+
8
+ const hasTestingLibrary = !!resolveModuleLocation("eslint-plugin-testing-library")
6
9
 
7
10
  const typeDefinitionOverride = typescriptConfig.overrides?.find(override =>
8
11
  override.files === "*.d.ts"
@@ -17,8 +20,6 @@ preventAbbreviationsConfig.allowList.Props = true
17
20
  preventAbbreviationsConfig.allowList.ref = true
18
21
  preventAbbreviationsConfig.allowList.Ref = true
19
22
 
20
- const { jestFilePatterns } = require("./lib/utils")
21
-
22
23
  /** @type {import("eslint").Linter.Config} */
23
24
  module.exports = {
24
25
  "extends": [
@@ -92,7 +93,9 @@ module.exports = {
92
93
  },
93
94
  {
94
95
  "files": jestFilePatterns,
95
- "extends": ["plugin:testing-library/react"]
96
+ "extends": hasTestingLibrary
97
+ ? ["plugin:testing-library/react"]
98
+ : []
96
99
  },
97
100
  typeDefinitionOverride
98
101
  ],
package/typescript.js CHANGED
@@ -2,8 +2,12 @@
2
2
  // Copyright 2024 Beslogic Inc.
3
3
 
4
4
  const javascriptConfig = require("./javascript")
5
- const { jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
6
- const { resolveModuleLocation } = require("./lib/utils")
5
+ const { jestNoRestrictedSyntax, jestFilePatterns, resolveModuleLocation } = require("./lib/utils")
6
+
7
+ // The only autofix we use is `no-implicit-any-catch` and this is a big module for pre-commit
8
+ // Outside of pre-commit, `eslint-plugin-etc` should NOT be considered optional !
9
+ const hasEtc = !!resolveModuleLocation("eslint-plugin-etc")
10
+ const hasTotalFunctions = !!resolveModuleLocation("eslint-plugin-total-functions")
7
11
 
8
12
  const commaDangleDefault = "always-multiline"
9
13
  const noRestrictedSyntax = [
@@ -23,8 +27,6 @@ const paddingLineBetweenStatementsConfig = javascriptConfig
23
27
  ?.find(override => override.extends === "plugin:autofix/all")
24
28
  ?.rules?.["autofix/padding-line-between-statements"]
25
29
 
26
- const hasTotalFunctions = !!resolveModuleLocation("eslint-plugin-total-functions")
27
-
28
30
  /** @type {import("eslint").Linter.Config} */
29
31
  module.exports = {
30
32
  "overrides": [
@@ -41,7 +43,9 @@ module.exports = {
41
43
  ...hasTotalFunctions
42
44
  ? ["plugin:total-functions/recommended"]
43
45
  : [],
44
- "plugin:etc/recommended",
46
+ ...hasEtc
47
+ ? ["plugin:etc/recommended"]
48
+ : [],
45
49
  "plugin:import/typescript"
46
50
  ],
47
51
  "env": {
@@ -106,7 +110,7 @@ module.exports = {
106
110
  "total-functions/no-enums": "off",
107
111
  // It takes an advanced TypeScript user to fully make sense of this rule
108
112
  /**
109
- * (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)
113
+ * (copied from https://dev.azure.com/Beslogic/Beslogic%20Architecture%20Reference/_wiki/wikis/Beslogic-Architecture-Reference.wiki/656/Frontend-linting-and-formatting?anchor=total-functions/no-unsafe-type-assertion)
110
114
  * It can sometimes be hard to make sense of this rule, but let's be strict!
111
115
  * Tips:
112
116
  * - Prefer coercion over assertion: `String(value ?? '')` over `value as string | null`
@@ -135,15 +139,21 @@ module.exports = {
135
139
  /*
136
140
  * Cartant's etc rules
137
141
  */
138
- "etc/no-const-enum": "error",
139
- // Same as total-functions/no-enums
140
- "etc/no-enum": "warn",
141
- "etc/throw-error": "error",
142
- "etc/underscore-internal": "error",
143
- // These two are extremely slow. More than should be expected
144
- // https://github.com/cartant/eslint-plugin-etc/issues/10#issuecomment-1618450905
145
- "etc/no-deprecated": "off",
146
- "etc/no-internal": "off",
142
+ ...hasEtc
143
+ ? {
144
+ "etc/no-const-enum": "error",
145
+ // Same as total-functions/no-enums
146
+ "etc/no-enum": "warn",
147
+ "etc/throw-error": "error",
148
+ "etc/underscore-internal": "error",
149
+ // These two are extremely slow. More than should be expected
150
+ // https://github.com/cartant/eslint-plugin-etc/issues/10#issuecomment-1618450905
151
+ "etc/no-deprecated": "off",
152
+ "etc/no-internal": "off",
153
+ // See https://github.com/cartant/eslint-plugin-etc/issues/45#issuecomment-1137305254
154
+ "etc/prefer-interface": "off"
155
+ }
156
+ : {},
147
157
 
148
158
  /*
149
159
  * Overrides of base Javascript rules
@@ -447,7 +457,10 @@ module.exports = {
447
457
  }
448
458
  ],
449
459
  // We accept nullish as falsy
450
- "@typescript-eslint/strict-boolean-expressions": "off",
460
+ "@typescript-eslint/strict-boolean-expressions": [
461
+ "off",
462
+ { "allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": true }
463
+ ],
451
464
  "@typescript-eslint/switch-exhaustiveness-check": [
452
465
  "error",
453
466
  {
@@ -1,16 +0,0 @@
1
- Thank you for your contribution to Beslogic's **ESLint-Config-Beslogic** repo.
2
- Before submitting this PR, please make sure:
3
-
4
- - [ ] The project is building
5
- - [ ] There are no linting issues
6
- - [ ] You updated the projects' README.md and CHANGELOG.md with the new changes
7
- - [ ] You reviewed your own PR and made sure there's no test/debug code or any obvious mistakes.
8
- - [ ] You set and configured auto-complete to "Complete associated work items after merging" & "Delete \<branch> after merging".
9
- - [ ] You cleaned up your commit history or set the PR Merge type to "Squash".
10
-
11
- Make sure that the code wasn't copied from elsewhere (check one):
12
-
13
- - [ ] This is your own original code
14
- - [ ] You have made sure that we have permission to use the copied code and that we follow its licensing
15
-
16
- _Add a short description_
@@ -1 +0,0 @@
1
- static-tests