@croct/eslint-plugin 0.8.2 → 0.8.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/README.md CHANGED
@@ -30,50 +30,86 @@ Webpack or Browserify:
30
30
  npm i -D @croct/eslint-plugin
31
31
  ```
32
32
 
33
- Then, add the following to your `.eslintrc.js` file:
33
+ This plugin uses ESLint's [flat config format](https://eslint.org/docs/latest/use/configure/configuration-files) (ESLint v9+).
34
+
35
+ ### JavaScript
36
+
37
+ For JavaScript projects, create an `eslint.config.mjs` file:
34
38
 
35
39
  ```js
36
- // Workaround for https://github.com/eslint/eslint/issues/3458
37
- require("@rushstack/eslint-patch/modern-module-resolution");
40
+ import { defineConfig } from 'eslint/config';
41
+ import croct from '@croct/eslint-plugin';
38
42
 
39
- module.exports = {
40
- "plugins": ["@croct"]
41
- }
43
+ export default defineConfig(
44
+ croct.configs.javascript,
45
+ );
42
46
  ```
43
47
 
44
- Note the `require` call at the top of the file. This is a workaround to avoid adding the transitive dependencies of
45
- the plugin to the project, which is [currently not supported by the ESLint plugin system](https://github.com/eslint/eslint/issues/3458).
46
-
47
48
  ### TypeScript
48
49
 
49
- For TypeScript projects, you need first to install the TypeScript parser:
50
+ For TypeScript projects, create an `eslint.config.mjs` file:
50
51
 
51
- ```sh
52
- npm i -D @typescript-eslint/parser
52
+ ```js
53
+ import { defineConfig } from 'eslint/config';
54
+ import croct from '@croct/eslint-plugin';
55
+
56
+ export default defineConfig(
57
+ croct.configs.typescript,
58
+ );
59
+ ```
60
+
61
+ The TypeScript config includes the JavaScript preset, so there's no need to include both.
62
+
63
+ ### React
64
+
65
+ For React projects, create an `eslint.config.mjs` file:
66
+
67
+ ```js
68
+ import { defineConfig } from 'eslint/config';
69
+ import croct from '@croct/eslint-plugin';
70
+
71
+ export default defineConfig(
72
+ croct.configs.react,
73
+ );
53
74
  ```
54
75
 
55
- Then, add the following to your `.eslintrc.js` file:
76
+ The React config includes the JavaScript preset, so there's no need to include both.
77
+
78
+ ### Cypress
79
+
80
+ For Cypress projects, create an `eslint.config.mjs` file:
81
+
82
+ ```js
83
+ import { defineConfig } from 'eslint/config';
84
+ import croct from '@croct/eslint-plugin';
85
+
86
+ export default defineConfig(
87
+ croct.configs.cypress,
88
+ );
89
+ ```
90
+
91
+ The Cypress config includes the JavaScript preset, so there's no need to include both.
92
+
93
+ ### Custom rules
94
+
95
+ You can add custom rules or override existing ones:
56
96
 
57
97
  ```js
58
- // Workaround for https://github.com/eslint/eslint/issues/3458
59
- require("@rushstack/eslint-patch/modern-module-resolution");
60
-
61
- module.exports = {
62
- "parser": "@typescript-eslint/parser",
63
- "plugins": [
64
- "@croct"
65
- ],
66
- "extends": [
67
- "plugin:@croct/typescript"
68
- ],
69
- "parserOptions": {
70
- "extends": "./tsconfig.json",
71
- "project": ["./tsconfig.json"]
98
+ import { defineConfig } from 'eslint/config';
99
+ import croct from '@croct/eslint-plugin';
100
+
101
+ export default defineConfig(
102
+ croct.configs.typescript,
103
+ {
104
+ files: ['src/**/*.ts'],
105
+ rules: {
106
+ '@typescript-eslint/explicit-function-return-type': 'off',
107
+ },
72
108
  },
73
- }
109
+ );
74
110
  ```
75
111
 
76
- For the list for available presets and rules, see the [reference documentation](docs/README.md).
112
+ For the list of available presets and rules, see the [reference documentation](docs/README.md).
77
113
 
78
114
  ## Basic usage
79
115
 
@@ -75,6 +75,7 @@ const baseRules = {
75
75
  'no-undef': 'off',
76
76
  '@typescript-eslint/no-namespace': 'off',
77
77
  '@typescript-eslint/restrict-template-expressions': 'off',
78
+ '@typescript-eslint/consistent-type-imports': 'error',
78
79
  // Disable rules that turn `any` into `unknown`, places where `unknown` is the preferred type
79
80
  // have that type already.
80
81
  '@typescript-eslint/no-unsafe-argument': 'off',
@@ -113,5 +114,13 @@ function createTypescriptConfig(plugin, javascriptConfig) {
113
114
  },
114
115
  rules: baseRules,
115
116
  },
117
+ {
118
+ name: '@croct/typescript-test-files',
119
+ files: ['**/*.test.ts', '**/*.test.tsx'],
120
+ rules: {
121
+ // Prevent false warnings when checking mocked interfaces
122
+ '@typescript-eslint/unbound-method': 'off',
123
+ },
124
+ },
116
125
  ];
117
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croct/eslint-plugin",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "ESLint rules and presets applied to all Croct JavaScript projects.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -53,7 +53,7 @@
53
53
  "typescript-eslint": "^8.53.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@types/jest": "^29.5.14",
56
+ "@types/jest": "^30.0.0",
57
57
  "@types/semver": "^7.5.8",
58
58
  "@typescript-eslint/parser": "^8.53.0",
59
59
  "@typescript-eslint/rule-tester": "^8.53.0",
@@ -62,7 +62,7 @@
62
62
  "eslint": "^9.28.0",
63
63
  "eslint-plugin-eslint-plugin": "^6.4.0",
64
64
  "eslint-plugin-self": "^1.2.1",
65
- "jest": "^29.7.0",
65
+ "jest": "^30.0.0",
66
66
  "ts-jest": "^29.3.4",
67
67
  "typescript": "~5.9.0"
68
68
  },