Skip to content

Commit 2e1edd8

Browse files
committed
Make flat configs accessible from root, add fixture test, deal with CJS/ESM for configs.
1 parent e28e18e commit 2e1edd8

File tree

17 files changed

+292
-168
lines changed

17 files changed

+292
-168
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: 51 additions & 9 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,25 +111,53 @@ options you can set.
100111
}
101112
```
102113

103-
## Flat Configuration
114+
### Flat Configuration
104115

105-
The configurations are also available [Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new) objects. They use the `"files"` key to apply to their respective file extensions (`.js`, `.mjs` and `.jsx` for the recommended configuration; `.ts` and `.tsx` for the typescript configuration). Alternatively you can import `eslint-plugin-solid` directly for a manual configuration as described above.
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`.
106121

107122
```js
108123
import js from "@eslint/js";
109-
import solid from "eslint-plugin-solid/dist/configs/recommended.js";
110-
import solidTS from "eslint-plugin-solid/dist/configs/typescript.js";
124+
import solid from "eslint-plugin-solid/configs/recommended";
111125

112126
export default [
113127
js.configs.recommended, // replaces eslint:recommended
114128
solid,
115-
solidTS // optional
116129
];
117130
```
118131

119-
These configurations do not configure global variables in ESLint. You can do this yourself manually or with a package like [globals](https://www.npmjs.com/package/globals) by creating a configuration with a `languageOptions.globals` object. We recommend setting up global variables for Browser APIs as well as at least ES2015.
132+
For TypeScript:
120133

121-
Note for VSCode Extension: Enable the "Use Flat Config" setting for your workspace to enable Flat Config support.
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.
122161

123162
## Rules
124163

@@ -154,7 +193,7 @@ Note for VSCode Extension: Enable the "Use Flat Config" setting for your workspa
154193
## Troubleshooting
155194

156195
The rules in this plugin provide sensible guidelines as well as possible, but there may be times
157-
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
158197
comment](https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules) like the
159198
following:
160199

@@ -163,10 +202,13 @@ following:
163202
const [editedValue, setEditedValue] = createSignal(props.value);
164203
```
165204

166-
_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,
167206
even if it looks like a false positive at first. With `solid/reactivity`, please look at the
168207
[reactivity docs](./docs/reactivity.md#troubleshooting) before deciding to disable the rule.
169208

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

172214
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)