Skip to content

feat: update to eslint 9 #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions .eslintrc.json

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/lint-prettier.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
uses: ./.github/workflows/lint-markdown.yml
lint_packages:
uses: ./.github/workflows/lint-packages.yml
lint_prettier:
uses: ./.github/workflows/lint-prettier.yml
lint_spelling:
uses: ./.github/workflows/lint-spelling.yml
test:
Expand All @@ -46,7 +44,6 @@ jobs:
- lint_markdown
- lint_spelling
- lint_packages
- lint_prettier
- test
- type_check
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
os:
- "ubuntu-latest"
node_version:
- "16"
- "18"
- "18.18"
- "20"
- "latest"
ts_version:
Expand Down
5 changes: 2 additions & 3 deletions .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"*.{json,yml}":
- prettier --ignore-unknown --write
- eslint --fix
- cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot

"*.ts":
- prettier --ignore-unknown --write
- eslint --fix
- cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot
- tsc-files -p tsconfig.build.json --noEmit

"*.md":
- prettier --ignore-unknown --write
- eslint --fix
- markdownlint --config=.markdownlint.json --ignore-path=.markdownlintignore
- cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot

Expand Down
21 changes: 15 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.fixAll.eslint": "explicit",
"source.formatDocument": "explicit",
"source.organizeImports": "explicit",
"source.sortImports": "explicit"
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.rulers": [80],
"eslint.probe": [
"html",
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"toml",
"typescript",
"typescriptreact",
"vue",
"yaml"
],
"files.associations": {
".markdownlint.json": "jsonc",
".markdownlintignore": "ignore"
Expand All @@ -29,6 +38,6 @@
},
"typescript.tsdk": "./node_modules/typescript/lib",
"[markdown]": {
"editor.rulers": [160]
"editor.rulers": [120]
}
}
116 changes: 43 additions & 73 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,97 +19,67 @@ pnpm add -D eslint eslint-plugin-functional

```sh
# Install with npm
npm install -D eslint @typescript-eslint/parser eslint-plugin-functional
npm install -D eslint typescript-eslint eslint-plugin-functional

# Install with yarn
yarn add -D eslint @typescript-eslint/parser eslint-plugin-functional
yarn add -D eslint typescript-eslint eslint-plugin-functional

# Install with pnpm
pnpm add -D eslint @typescript-eslint/parser eslint-plugin-functional
pnpm add -D eslint typescript-eslint eslint-plugin-functional
```

## Usage

### Flat Config
### Without TypeScript

If using the new [flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new),
import from `eslint-plugin-functional/flat`.
In your `eslint.config.js` file, import `eslint-plugin-functional` and configure it as you wish.

```ts
import functional from "eslint-plugin-functional/flat";
```

### Classic Config
If you're not using TypeScript, be sure to include the `disableTypeChecked` config after the other configs to
disable rules that require TypeScript.

Add `functional` to the plugins section of your `.eslintrc` configuration file. Then configure the rules you want to use under the rules section.
```js
// eslint.config.js
import functional from "eslint-plugin-functional";

```jsonc
{
"plugins": ["functional"],
"rules": {
"functional/rule-name": "error"
}
}
```

There are several rulesets provided by this plugin.
[See the README](./README.md#rulesets) for what they are and what rules are included in each.
Enable rulesets via the "extends" property of your `.eslintrc` configuration file.

Be sure to include the `"plugin:functional/disable-type-checked"` ruleset to disable rules that require TypeScript.

```jsonc
{
// ...
"extends": [
"plugin:functional/external-vanilla-recommended",
"plugin:functional/recommended",
"plugin:functional/stylistic",
"plugin:functional/disable-type-checked"
]
}
export default [
...functional.configs.externalVanillaRecommended,
...functional.configs.recommended,
...functional.configs.stylistic,
...functional.configs.disableTypeChecked,
// your other plugin configs here
{
rules: {
// any rule configs here
},
},
];
```

### With TypeScript

Add `@typescript-eslint/parser` to the "parser" filed in your `.eslintrc` configuration file.
To use type information, you will need to specify a path to your `tsconfig.json` file in the "project" property of "parserOptions".
Alternatively, you can just set "project" to `true` to automatically use the nearest `tsconfig.json` files.

```jsonc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
}
}
```

See [@typescript-eslint/parser's README.md](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/parser#readme) for more information on the available parser options.
In your `eslint.config.js` file, import `typescript-eslint` and `eslint-plugin-functional` and configure them as you wish.

### Example Config
```js
// eslint.config.js
import functional from "eslint-plugin-functional";
import tseslint from "typescript-eslint";

```jsonc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
export default tseslint.config({
files: ["**/*.ts"],
extends: [
functional.configs.externalVanillaRecommended,
functional.configs.recommended,
functional.configs.stylistic,
// your other plugin configs here
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
"env": {
"es6": true
rules: {
// any rule configs here
},
"plugins": [
"@typescript-eslint",
"functional"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:functional/external-typescript-recommended",
"plugin:functional/recommended",
"plugin:functional/stylistic"
]
}
});
```
Loading