You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can declare custom rules in this directory and import them from our ESLint config in [eslint.config.ts](../../eslint.config.ts)
4
+
5
+
Custom rules are useful for enforcing best practices and more effective than a "warning" comment since automated linter tests will fail if custom rules aren't followed.
6
+
7
+
**Note:** Custom rules must be written as JavaScript (`.js`) files, not TypeScript. ESLint loads custom rule plugins at runtime using Node's module system, which expects JavaScript. While the main ESLint config can be TypeScript, the rule implementations themselves need to be JavaScript.
8
+
9
+
## Creating a new rule
10
+
11
+
1. Create the rule in this directory
12
+
2. Export it from [index.js](./index.js)
13
+
3. Enable it in [eslint.config.ts](../../eslint.config.ts) under the `"rules"` key, e.g.
14
+
15
+
```typescript
16
+
'custom-rules/use-custom-logger': 'error',
17
+
```
18
+
19
+
Note that the rule is prepended with `custom-rules`
20
+
21
+
4. Please include a `README.md` in your rule's directory explaining why it is necessary and any times the rule can be ignored.
0 commit comments