@mscharley/eslint-config 4.0.1 → 4.0.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,5 +1,19 @@
1
1
  # Change Log - @mscharley/eslint-config
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 7d2169b: Prevent better support for linting JS files
8
+ - 4872523: Apply testing fixes to **mocks** as well as **utils**
9
+
10
+ ## 4.0.2
11
+
12
+ ### Patch Changes
13
+
14
+ - ab92718: Cleanup some of the testing rules
15
+ - 7d6a205: Fix readme for flat configurations
16
+
3
17
  ## 4.0.1
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -20,15 +20,15 @@ $ npm install --save-dev @mscharley/eslint-config
20
20
  ## Usage
21
21
 
22
22
  ```js
23
- // .eslintrc.js
24
- module.exports = {
25
- root: true,
26
- extends: [
27
- '@mscharley', // Baseline rules for any TS or JS project.
28
- '@mscharley/eslint-config/node', // For projects running on NodeJS.
29
- // '@mscharley/eslint-config/react', // For projects running React.
30
- ],
31
- };
23
+ // eslint.config.js
24
+ import { configs, withStyles } from "@mscharley/eslint-config";
25
+
26
+ export const [
27
+ ...configs.recommended,
28
+ ...configs.node, // For projects running on NodeJS
29
+ // ...configs.react, // For projects running React
30
+ ...withStyles(), // Include formatting rules
31
+ ];
32
32
  ```
33
33
 
34
34
  ### Notes on Prettier
@@ -45,24 +45,13 @@ If using Prettier to format files other than TypeScript and JavaScript files the
45
45
  **/*.js
46
46
  ```
47
47
 
48
- ## Extras
48
+ ### Usage in JavaScript projects
49
49
 
50
- ### Deprecation warnings for JavaScript files
51
-
52
- As a general rule we can't enable the `deprecation/deprecation` rule for JavaScript files because this rule requires TypeScript type information to work. If you have a mixed TypeScript/JavaScript project then you can enable it for the JavaScript files inside your TypeScript project using the following override:
53
-
54
- ```js
55
- // .eslintrc.js
56
- module.exports = {
57
- overrides: [
58
- {
59
- // This must be a valid path inside your TypeScript source folders.
60
- files: ["src/**/*.{js,jsx}"],
61
- rules: { "deprecation/deprecation": "warn" },
62
- },
63
- ],
64
- };
65
50
  ```
51
+ Parsing error: [...]/configFile.js was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject
52
+ ```
53
+
54
+ If you get messages like this, you can disable type-checked rules using the `disableTypeCheckedRules()` helper function exported by this module. This takes a list of file paths and returns a single configuration object. This takes into account all type checked rules enabled by this configuration and is a superset of the helper configuration provided by `typescript-eslint` for a similar purpose.
66
55
 
67
56
  [gh-contrib]: https://github.com/mscharley/node-presets/graphs/contributors
68
57
  [gh-issues]: https://github.com/mscharley/node-presets/issues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mscharley/eslint-config",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "type": "module",
5
5
  "module": "./rules/index.js",
6
6
  "exports": {
package/rules/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ import typescript, { disableTypeCheckedRules } from './typescript.js';
1
2
  import eslint from './eslint.js';
2
3
  import node from './node.js';
3
4
  import react from './react.js';
4
5
  import stylistic from '@stylistic/eslint-plugin';
5
6
  import testing from './testing.js';
6
- import typescript from './typescript.js';
7
7
 
8
8
  export const configs = {
9
9
  recommended: [
@@ -37,4 +37,6 @@ export const withStyles = () => [
37
37
  },
38
38
  ];
39
39
 
40
- export default { configs, withStyles };
40
+ export { disableTypeCheckedRules };
41
+
42
+ export default { configs, disableTypeCheckedRules, withStyles };
package/rules/testing.js CHANGED
@@ -22,6 +22,7 @@ export default [
22
22
  files: jestFiles,
23
23
  rules: {
24
24
  '@typescript-eslint/consistent-type-assertions': 'off',
25
+ '@typescript-eslint/no-magic-numbers': 'off',
25
26
  'jest/prefer-todo': 'error',
26
27
  'jest/no-conditional-in-test': 'warn',
27
28
  'jest/no-untyped-mock-factory': 'error',
@@ -35,4 +36,13 @@ export default [
35
36
  ],
36
37
  },
37
38
  },
39
+ {
40
+ files: [
41
+ '**/__mocks__/**/*.{ts,js,tsx,jsx}',
42
+ '**/__utils__/**/*.{ts,js,tsx,jsx}',
43
+ ],
44
+ rules: {
45
+ 'jest/no-export': 'off',
46
+ },
47
+ },
38
48
  ];
@@ -1,5 +1,15 @@
1
1
  import { configs as tseslint } from 'typescript-eslint';
2
2
 
3
+ export const disableTypeCheckedRules = (...files) => ({
4
+ files,
5
+ ...tseslint.disableTypeChecked,
6
+ rules: {
7
+ ...tseslint.disableTypeChecked.rules,
8
+ '@typescript-eslint/explicit-function-return-type': 'off',
9
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
10
+ },
11
+ });
12
+
3
13
  /** @type import('eslint').Config[] */
4
14
  export default [
5
15
  ...tseslint.recommendedTypeChecked,
@@ -11,9 +21,6 @@ export default [
11
21
  },
12
22
  },
13
23
  {
14
- files: [
15
- '**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts',
16
- ],
17
24
  rules: {
18
25
  '@typescript-eslint/no-deprecated': 'warn',
19
26
  '@typescript-eslint/array-type': [
@@ -128,8 +135,13 @@ export default [
128
135
  '@typescript-eslint/no-unused-vars': [
129
136
  'warn',
130
137
  {
138
+ args: 'all',
131
139
  argsIgnorePattern: '^_',
140
+ caughtErrors: 'all',
141
+ caughtErrorsIgnorePattern: '^_',
142
+ destructuredArrayIgnorePattern: '^_',
132
143
  varsIgnorePattern: '^_',
144
+ ignoreRestSiblings: true,
133
145
  },
134
146
  ],
135
147
  '@typescript-eslint/no-unnecessary-boolean-literal-compare': [
@@ -174,4 +186,5 @@ export default [
174
186
  '@typescript-eslint/switch-exhaustiveness-check': 'error',
175
187
  },
176
188
  },
189
+ disableTypeCheckedRules('*.config.js'),
177
190
  ];