Skip to content

Commit 736a074

Browse files
authored
docs(eslint-plugin): explicitly document mixed codebase usage fo… (#939)
1 parent ccb98d8 commit 736a074

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

packages/eslint-plugin/docs/rules/explicit-function-return-type.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,28 @@ const defaults = {
7878
};
7979
```
8080

81+
### Configuring in a mixed JS/TS codebase
82+
83+
If you are working on a codebase within which you lint non-TypeScript code (i.e. `.js`/`.jsx`), you should ensure that you should use [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files) to only enable the rule on `.ts`/`.tsx` files. If you don't, then you will get unfixable lint errors reported within `.js`/`.jsx` files.
84+
85+
```jsonc
86+
{
87+
"rules": {
88+
// disable the rule for all files
89+
"@typescript-eslint/explicit-function-return-type": "off"
90+
},
91+
"overrides": [
92+
{
93+
// enable the rule specifically for TypeScript files
94+
"files": ["*.ts", "*.tsx"],
95+
"rules": {
96+
"@typescript-eslint/explicit-function-return-type": ["error"]
97+
}
98+
}
99+
]
100+
}
101+
```
102+
81103
### allowExpressions
82104

83105
Examples of **incorrect** code for this rule with `{ allowExpressions: true }`:

packages/eslint-plugin/docs/rules/explicit-member-accessibility.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type AccessibilityLevel =
1818
| 'no-public' // don't require public
1919
| 'off'; // don't check
2020

21-
interface Config {
21+
type Options = {
2222
accessibility?: AccessibilityLevel;
2323
overrides?: {
2424
accessors?: AccessibilityLevel;
@@ -28,14 +28,36 @@ interface Config {
2828
parameterProperties?: AccessibilityLevel;
2929
};
3030
}
31+
32+
const defaultOptions: Options = {
33+
accessibility: 'explicit',
34+
};
3135
```
3236

33-
Default config:
37+
### Configuring in a mixed JS/TS codebase
38+
39+
If you are working on a codebase within which you lint non-TypeScript code (i.e. `.js`/`.jsx`), you should ensure that you should use [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files) to only enable the rule on `.ts`/`.tsx` files. If you don't, then you will get unfixable lint errors reported within `.js`/`.jsx` files.
3440

35-
```JSON
36-
{ "accessibility": "explicit" }
41+
```jsonc
42+
{
43+
"rules": {
44+
// disable the rule for all files
45+
"@typescript-eslint/explicit-member-accessibility": "off"
46+
},
47+
"overrides": [
48+
{
49+
// enable the rule specifically for TypeScript files
50+
"files": ["*.ts", "*.tsx"],
51+
"rules": {
52+
"@typescript-eslint/explicit-member-accessibility": ["error"]
53+
}
54+
}
55+
]
56+
}
3757
```
3858

59+
### `accessibility`
60+
3961
This rule in it's default state requires no configuration and will enforce that every class member has an accessibility modifier. If you would like to allow for some implicit public members then you have the following options:
4062
A possible configuration could be:
4163

0 commit comments

Comments
 (0)