eslint-config-beslogic 5.2.2 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.2.3
4
+
5
+ - `unicorn/prevent-abbreviations` in `react` preset allow "Prop" abbreviation to allow "PropTypes" constants
6
+ - Added `"incremental": true` and `"strictNullChecks": true` to shared `tsconfig.json`
7
+ - Fixed type-checking issues in source so that pure-JS projects with `"checkJs": true` don't fail type-checking
8
+
3
9
  ## 5.2.2
4
10
 
5
- - Don't sort alphabetically by default in `@stylistic/jsx-sort-props`
11
+ - Don't sort alphabetically in `@stylistic/jsx-sort-props` in non-extra-strict preset
6
12
 
7
13
  ## 5.2.1
8
14
 
package/angular.mjs CHANGED
@@ -21,7 +21,11 @@ const typescriptVersion = getModuleVersion("typescript", 99)
21
21
  const typeDeclarationOverride = beslogicTypeScript.find(
22
22
  config => config.name === "beslogic/typescript/type-declaration"
23
23
  )
24
+ if (!typeDeclarationOverride) {
25
+ throw new TypeError("beslogic/typescript/type-declaration config not found in typescript.mjs")
26
+ }
24
27
 
28
+ /** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
25
29
  export const noRestrictedSyntax = [
26
30
  ...noRestrictedSyntaxJS,
27
31
  // TODO: Possibly implement that ourselves?
package/extra-strict.mjs CHANGED
@@ -32,11 +32,12 @@ export const explicitModuleBoundaryType = [
32
32
  }
33
33
  ]
34
34
 
35
+ /** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
35
36
  export const noRestrictedSyntax = [
36
37
  ...noRestrictedSyntaxTS,
37
38
  // TODO: This would really be better as its own rule.
38
39
  // My understanding is that it only negatively affects published libs,
39
- // and even then there's way o work around it.
40
+ // and even then there's ways to work around it.
40
41
  // Ban `const` enums: https://typescript-eslint.io/troubleshooting/faqs/general/#how-can-i-ban-specific-language-feature
41
42
  {
42
43
  "selector": "TSEnumDeclaration[const=true]",
@@ -53,10 +54,13 @@ export default defineConfig(
53
54
  "**/*.tsx"
54
55
  ],
55
56
  "rules": {
56
- "@stylistic/jsx-sort-props": ["error", {
57
- ...jsxSortPropsConfig,
58
- "noSortAlphabetically": false
59
- }],
57
+ "@stylistic/jsx-sort-props": [
58
+ "error",
59
+ {
60
+ ...jsxSortPropsConfig,
61
+ "noSortAlphabetically": false
62
+ }
63
+ ],
60
64
 
61
65
  // This is caught when noImplicitThis is enabled, which we assume in this config
62
66
  // https://typescript-eslint.io/rules/no-invalid-this/
package/javascript.mjs CHANGED
@@ -33,6 +33,7 @@ export const restrictedGlobals = [
33
33
  }
34
34
  ]
35
35
 
36
+ /** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
36
37
  export const noRestrictedSyntax = [
37
38
  "error",
38
39
  "WithStatement",
@@ -88,6 +89,8 @@ export const noMagicNumbersConfig = {
88
89
  }
89
90
  : {}
90
91
  }
92
+
93
+ /** @type {[import('@eslint/core').Severity, Record<string, string | boolean>]} */
91
94
  export const noUnusedVariables = [
92
95
  "error",
93
96
  {
@@ -101,6 +104,7 @@ export const noUnusedVariables = [
101
104
  ]
102
105
  // Same as S00107
103
106
  // Projects with dependency Injection (Angular) also need more params in their constructor
107
+ /** @type {[import('@eslint/core').Severity, { max: number }]} */
104
108
  export const maxParams = [
105
109
  "error",
106
110
  { "max": 7 }
@@ -207,6 +211,9 @@ export default defineConfig(
207
211
  sonarjs.configs.recommended,
208
212
  eslintPluginUnicorn.configs["flat/all"],
209
213
  regexp.configs["flat/recommended"],
214
+ // @ts-ignore
215
+ // - https://github.com/un-ts/eslint-plugin-import-x/issues/439
216
+ // - https://github.com/typescript-eslint/typescript-eslint/issues/11543
210
217
  importX.flatConfigs.recommended,
211
218
  comments.recommended,
212
219
  {
package/lib/utils.mjs CHANGED
@@ -31,16 +31,16 @@ export const resolveModuleLocation = (/** @type {string} */ nodeModule) => {
31
31
  }
32
32
 
33
33
  export const jestNoRestrictedSyntax = (
34
- /** @type {(string | number | { selector: string; })[]} */ noRestrictedSyntax
35
- ) =>
36
- noRestrictedSyntax.filter(
37
- entry =>
38
- typeof entry === "number"
39
- || typeof entry === "string"
40
- // Exclude from jest tests for compatibility with
41
- // `jest/valid-describe-callback` and `jest/no-test-return-statement`
42
- || !entry.selector.startsWith("ArrowFunctionExpression")
43
- )
34
+ /** @type {readonly (number | string | {readonly selector: string})[]} */ noRestrictedSyntax
35
+ // eslint-disable-next-line @stylistic/no-extra-parens -- https://github.com/eslint-stylistic/eslint-stylistic/issues/1088
36
+ ) => /** @type {import('@eslint/config-helpers').RuleConfig} */ (noRestrictedSyntax.filter(
37
+ entry =>
38
+ typeof entry === "number"
39
+ || typeof entry === "string"
40
+ // Exclude from jest tests for compatibility with
41
+ // `jest/valid-describe-callback` and `jest/no-test-return-statement`
42
+ || !entry.selector.startsWith("ArrowFunctionExpression")
43
+ ))
44
44
 
45
45
  // Matching Jest's own default file patterns: https://jestjs.io/docs/configuration#testmatch-arraystring
46
46
  export const jestFilePatterns = [
@@ -86,6 +86,7 @@ export const idLenghtConfig = {
86
86
  ]
87
87
  }
88
88
 
89
+ // eslint-disable-next-line unicorn/prevent-abbreviations -- Props allowed in React
89
90
  export const jsxSortPropsConfig = {
90
91
  // Keeping special props first, and not hiding props under big multiline
91
92
  // both help a lot with readability and semantics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-beslogic",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
4
4
  "description": "ESLint rules, plugins and configs used at Beslogic",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -8,8 +8,8 @@
8
8
  "scripts": {
9
9
  "eslint-unstable-flag": "set TIMING=1 && eslint . --flag unstable_config_lookup_from_file",
10
10
  "eslint": "set TIMING=1 && eslint . --flag v10_config_lookup_from_file",
11
- "lint": "dprint check && npm run eslint",
12
- "lint:fix": "npm run eslint -- --fix && dprint fmt",
11
+ "lint": "dprint check && npm run eslint && tsc",
12
+ "lint:fix": "npm run eslint -- --fix && dprint fmt && tsc",
13
13
  "upgrade": "npx npm-check-updates -u & npm i",
14
14
  "prepack": "type .gitignore* > .npmignore",
15
15
  "postinstall": "node ./lib/patch-dependencies.mjs",
package/react.mjs CHANGED
@@ -16,8 +16,9 @@ import beslogicTypeScript from "./typescript.mjs"
16
16
  const typeDeclarationOverride = beslogicTypeScript.find(
17
17
  config => config.name === "beslogic/typescript/type-declaration"
18
18
  )
19
-
20
- if (!typeDeclarationOverride) throw new TypeError("**/*.d.ts not found in typescript.mjs")
19
+ if (!typeDeclarationOverride) {
20
+ throw new TypeError("beslogic/typescript/type-declaration config not found in typescript.mjs")
21
+ }
21
22
 
22
23
  const preventAbbreviationsConfig = { ...preventAbbreviationsConfigJS }
23
24
  // React props
@@ -25,6 +26,9 @@ preventAbbreviationsConfig.allowList.props = true
25
26
  preventAbbreviationsConfig.allowList.Props = true
26
27
  preventAbbreviationsConfig.allowList.ref = true
27
28
  preventAbbreviationsConfig.allowList.Ref = true
29
+ preventAbbreviationsConfig.allowList.PropTypes = true
30
+ // Apparently Trying to set "PropTypes" doesn't work
31
+ preventAbbreviationsConfig.allowList.Prop = true
28
32
  // useState's set method using the previous state
29
33
  // Note: It's still better to name it like prevSomething
30
34
  preventAbbreviationsConfig.allowList.prev = true
@@ -96,7 +100,10 @@ export default defineConfig(
96
100
  * Stylistic overrides https://eslint.style/rules
97
101
  */
98
102
  "react/jsx-sort-props": "off",
99
- "@stylistic/jsx-sort-props": ["error", jsxSortPropsConfig],
103
+ "@stylistic/jsx-sort-props": [
104
+ "error",
105
+ jsxSortPropsConfig
106
+ ],
100
107
 
101
108
  /*
102
109
  * react overrides (https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules)
package/tsconfig.4.3.json CHANGED
@@ -5,12 +5,14 @@
5
5
  "compilerOptions": {
6
6
  "strict": true,
7
7
  "checkJs": true,
8
+ "incremental": true, // Performance improvement during dev through incremental checking
8
9
  "newLine": "LF", // Now default in TypeScript 5.0
9
10
  "forceConsistentCasingInFileNames": true, // Now default in TypeScript 5.0
10
11
  "resolveJsonModule": true,
11
12
  "noFallthroughCasesInSwitch": true,
12
13
  "noImplicitOverride": true,
13
14
  "noImplicitReturns": true,
15
+ "strictNullChecks": true, // Stop hiding null/undefined types, *even* with strict=false !
14
16
  // This makes index accesses even stricter. You may not want it in your project.
15
17
  // You should probably disable it at least in tests.
16
18
  "noUncheckedIndexedAccess": true,
package/tsconfig.json CHANGED
@@ -12,5 +12,9 @@
12
12
  "jsx": "react-jsx",
13
13
  "allowJs": true,
14
14
  "noImplicitAny": false,
15
+ // Some issues in upstream .d.ts imports
16
+ "skipLibCheck": true,
17
+ // Necessary as long as we still test old-style Angular decorators
18
+ "experimentalDecorators": true,
15
19
  },
16
20
  }
package/typescript.mjs CHANGED
@@ -11,6 +11,7 @@ import { maxParams, noMagicNumbersConfig as noMagicNumbersConfigJS, noRestricted
11
11
  import beslogicJest from "./jest.mjs"
12
12
  import { jestFilePatterns, jestNoRestrictedSyntax } from "./lib/utils.mjs"
13
13
 
14
+ /** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
14
15
  export const noRestrictedSyntax = [
15
16
  ...noRestrictedSyntaxJS,
16
17
  {