Skip to content

Commit

Permalink
Merge pull request #96 from Mitsunee/add-flat-config-docs
Browse files Browse the repository at this point in the history
Add basic Flat Config setup to README
  • Loading branch information
joshwilsonvu committed Aug 19, 2023
2 parents 7cb891d + 2e1edd8 commit 72a7ed7
Show file tree
Hide file tree
Showing 18 changed files with 419 additions and 255 deletions.
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
./dist
./configs
node_modules
jest.config.js
./jest.config.js
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"plugins": ["solid"],
"extends": "plugin:solid/recommended",
"rules": {
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-empty-function": 0
}
Expand Down
66 changes: 64 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ migrate some React patterns to Solid code.
It's approaching a `1.0.0` release, and it's well tested and should be helpful in Solid projects
today.

<!-- AUTO-GENERATED-CONTENT:START (TOC) -->
- [Installation](#installation)
- [Configuration](#configuration)
- [TypeScript](#typescript)
- [Manual Configuration](#manual-configuration)
- [Flat Configuration](#flat-configuration)
- [Rules](#rules)
- [Troubleshooting](#troubleshooting)
- [Versioning](#versioning)
<!-- AUTO-GENERATED-CONTENT:END -->

## Installation

Install `eslint` and `eslint-plugin-solid` locally.
Expand Down Expand Up @@ -100,6 +111,54 @@ options you can set.
}
```

### Flat Configuration

ESLint's new configuration system, [Flat
Configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new#using-configurations-included-in-plugins),
is available starting in ESLint [v8.23.0](https://github.com/eslint/eslint/releases/tag/v8.23.0). To
use it, create an `eslint.config.js` file at the root of your project, instead of `.eslintrc.*`
and/or `.eslintignore`.

```js
import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/recommended";

export default [
js.configs.recommended, // replaces eslint:recommended
solid,
];
```

For TypeScript:

```js
import js from "@eslint/js";
import solid from 'eslint-plugin-solid/configs/typescript';
import * as tsParser from "@typescript-eslint/parser",

export default [
js.configs.recommended,
{
files: ["**/*.{ts,tsx}"],
...solid,
languageOptions: {
parser: tsParser,
parserOptions: {
project: 'tsconfig.json',
},
},
},
]
```

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.

Note for the ESLint VSCode Extension: Enable the "Use Flat Config" setting for your workspace to
enable Flat Config support.

## Rules

✔: Enabled in the `recommended` configuration.
Expand Down Expand Up @@ -134,7 +193,7 @@ options you can set.
## Troubleshooting

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

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

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

When in doubt, feel free to [file an
issue](https://github.com/solidjs-community/eslint-plugin-solid/issues/new/choose).

## Versioning

Pre-1.0.0, the rules and the `recommended` and `typescript` configuations will be
Expand Down
4 changes: 4 additions & 0 deletions configs/recommended.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "eslint-plugin-solid/configs/recommended" {
const config: typeof import("../src/configs/recommended");
export = config;
}
1 change: 1 addition & 0 deletions configs/recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../dist/configs/recommended");
4 changes: 4 additions & 0 deletions configs/typescript.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "eslint-plugin-solid/configs/typescript" {
const config: typeof import("../src/configs/typescript");
export = config;
}
1 change: 1 addition & 0 deletions configs/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../dist/configs/typescript");
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
"devDependencies": {
"@babel/core": "^7.21.3",
"@babel/eslint-parser": "^7.21.3",
"@eslint/js": "^8.44.0",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^14.1.0",
"@types/eslint": "^8.21.2",
"@types/eslint": "^8.40.2",
"@types/fs-extra": "^9.0.13",
"@types/is-html": "^2.0.0",
"@types/jest": "^27.5.2",
Expand All @@ -58,7 +59,7 @@
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"eslint": "^8.36.0",
"eslint": "^8.43.0",
"eslint-plugin-eslint-plugin": "^5.0.8",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-solid": "link:",
Expand All @@ -74,7 +75,7 @@
"markdown-magic": "^2.6.1",
"prettier": "^2.8.4",
"rollup": "^2.79.1",
"ts-jest": "^29.0.5",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.0.2"
},
Expand Down
Loading

0 comments on commit 72a7ed7

Please sign in to comment.