Skip to content

Commit 72a7ed7

Browse files
authored
Merge pull request #96 from Mitsunee/add-flat-config-docs
Add basic Flat Config setup to README
2 parents 7cb891d + 2e1edd8 commit 72a7ed7

File tree

18 files changed

+419
-255
lines changed

18 files changed

+419
-255
lines changed

.eslintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
dist
1+
./dist
2+
./configs
23
node_modules
3-
jest.config.js
4+
./jest.config.js

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"plugins": ["solid"],
5858
"extends": "plugin:solid/recommended",
5959
"rules": {
60+
"@typescript-eslint/no-unused-vars": 0,
6061
"@typescript-eslint/ban-ts-comment": 0,
6162
"@typescript-eslint/no-empty-function": 0
6263
}

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ migrate some React patterns to Solid code.
1616
It's approaching a `1.0.0` release, and it's well tested and should be helpful in Solid projects
1717
today.
1818

19+
<!-- AUTO-GENERATED-CONTENT:START (TOC) -->
20+
- [Installation](#installation)
21+
- [Configuration](#configuration)
22+
- [TypeScript](#typescript)
23+
- [Manual Configuration](#manual-configuration)
24+
- [Flat Configuration](#flat-configuration)
25+
- [Rules](#rules)
26+
- [Troubleshooting](#troubleshooting)
27+
- [Versioning](#versioning)
28+
<!-- AUTO-GENERATED-CONTENT:END -->
29+
1930
## Installation
2031

2132
Install `eslint` and `eslint-plugin-solid` locally.
@@ -100,6 +111,54 @@ options you can set.
100111
}
101112
```
102113

114+
### Flat Configuration
115+
116+
ESLint's new configuration system, [Flat
117+
Configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new#using-configurations-included-in-plugins),
118+
is available starting in ESLint [v8.23.0](https://github.com/eslint/eslint/releases/tag/v8.23.0). To
119+
use it, create an `eslint.config.js` file at the root of your project, instead of `.eslintrc.*`
120+
and/or `.eslintignore`.
121+
122+
```js
123+
import js from "@eslint/js";
124+
import solid from "eslint-plugin-solid/configs/recommended";
125+
126+
export default [
127+
js.configs.recommended, // replaces eslint:recommended
128+
solid,
129+
];
130+
```
131+
132+
For TypeScript:
133+
134+
```js
135+
import js from "@eslint/js";
136+
import solid from 'eslint-plugin-solid/configs/typescript';
137+
import * as tsParser from "@typescript-eslint/parser",
138+
139+
export default [
140+
js.configs.recommended,
141+
{
142+
files: ["**/*.{ts,tsx}"],
143+
...solid,
144+
languageOptions: {
145+
parser: tsParser,
146+
parserOptions: {
147+
project: 'tsconfig.json',
148+
},
149+
},
150+
},
151+
]
152+
```
153+
154+
These configurations do not configure global variables in ESLint. You can do this yourself manually
155+
or with a package like [globals](https://www.npmjs.com/package/globals) by creating a configuration
156+
with a `languageOptions.globals` object. We recommend setting up global variables for Browser APIs
157+
as well as at least ES2015.
158+
159+
Note for the ESLint VSCode Extension: Enable the "Use Flat Config" setting for your workspace to
160+
enable Flat Config support.
161+
103162
## Rules
104163

105164
✔: Enabled in the `recommended` configuration.
@@ -134,7 +193,7 @@ options you can set.
134193
## Troubleshooting
135194

136195
The rules in this plugin provide sensible guidelines as well as possible, but there may be times
137-
where the you better than the rule and want to ignore a warning. Just [add a
196+
where you know better than the rule and want to ignore a warning. To do that, [add a
138197
comment](https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules) like the
139198
following:
140199

@@ -143,10 +202,13 @@ following:
143202
const [editedValue, setEditedValue] = createSignal(props.value);
144203
```
145204

146-
_However_, there may also be times where a rule correctly warns about a subtle problem,
205+
_Please note_: there may also be times where a rule correctly warns about a subtle problem,
147206
even if it looks like a false positive at first. With `solid/reactivity`, please look at the
148207
[reactivity docs](./docs/reactivity.md#troubleshooting) before deciding to disable the rule.
149208

209+
When in doubt, feel free to [file an
210+
issue](https://github.com/solidjs-community/eslint-plugin-solid/issues/new/choose).
211+
150212
## Versioning
151213

152214
Pre-1.0.0, the rules and the `recommended` and `typescript` configuations will be

configs/recommended.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "eslint-plugin-solid/configs/recommended" {
2+
const config: typeof import("../src/configs/recommended");
3+
export = config;
4+
}

configs/recommended.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("../dist/configs/recommended");

configs/typescript.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "eslint-plugin-solid/configs/typescript" {
2+
const config: typeof import("../src/configs/typescript");
3+
export = config;
4+
}

configs/typescript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("../dist/configs/typescript");

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
"devDependencies": {
4747
"@babel/core": "^7.21.3",
4848
"@babel/eslint-parser": "^7.21.3",
49+
"@eslint/js": "^8.44.0",
4950
"@rollup/plugin-commonjs": "^22.0.2",
5051
"@rollup/plugin-json": "^4.1.0",
5152
"@rollup/plugin-node-resolve": "^14.1.0",
52-
"@types/eslint": "^8.21.2",
53+
"@types/eslint": "^8.40.2",
5354
"@types/fs-extra": "^9.0.13",
5455
"@types/is-html": "^2.0.0",
5556
"@types/jest": "^27.5.2",
@@ -58,7 +59,7 @@
5859
"@types/prettier": "^2.7.2",
5960
"@typescript-eslint/eslint-plugin": "^5.55.0",
6061
"@typescript-eslint/parser": "^5.55.0",
61-
"eslint": "^8.36.0",
62+
"eslint": "^8.43.0",
6263
"eslint-plugin-eslint-plugin": "^5.0.8",
6364
"eslint-plugin-import": "^2.27.5",
6465
"eslint-plugin-solid": "link:",
@@ -74,7 +75,7 @@
7475
"markdown-magic": "^2.6.1",
7576
"prettier": "^2.8.4",
7677
"rollup": "^2.79.1",
77-
"ts-jest": "^29.0.5",
78+
"ts-jest": "^29.1.1",
7879
"ts-node": "^10.9.1",
7980
"typescript": "^5.0.2"
8081
},

0 commit comments

Comments
 (0)