Skip to content

Commit

Permalink
feat(tasks): Enable tasks/lint_rules(JS ver) (#2177)
Browse files Browse the repository at this point in the history
- [x] Remove old task(Rust ver)
- [x] Migrate to new task(JS ver)
- [x] Confirm CI works w/o `--output`
-
https://github.com/oxc-project/oxc/actions/runs/7663961642/job/20887579432?pr=2177
- [x] Confirm CI works w/ fake issue no
  - #2117
- [x] Enable

- - -

I've noticed that

- eslint/no-extra-semi
- eslint/no-mixed-spaces-and-tabs

are maked as deprecated and also recommended.

This is ESLint side
[issue](eslint/eslint#17696 (comment))
and will fix after v9.
  • Loading branch information
leaysgur authored Jan 26, 2024
1 parent ea8cc98 commit cba8a4c
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 386 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/lint-rules.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update lint_rules list
name: Update implementation status of all linter plugins

on:
push:
Expand All @@ -11,21 +11,20 @@ on:
jobs:
lint_rules:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Branch
uses: actions/checkout@v4

- name: Install Rust
uses: moonrepo/setup-rust@v1 # Cache everything to speed up compilation
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache-base: main
node-version: 20

- name: Build lint_rules task
run: cargo build -p lint_rules
- name: Install latest plugins
working-directory: tasks/lint_rules
run: npm install

- name: Update eslint
run: cargo run -p lint_rules eslint --update
- name: Update @typescript-eslint
run: cargo run -p lint_rules typescript --update
- name: Run task
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node ./tasks/lint_rules --update
14 changes: 0 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = ["crates/*", "tasks/*", "napi/*"]
exclude = ["tasks/lint_rules2"]
exclude = ["tasks/lint_rules"]

[workspace.package]
authors = ["Boshen <[email protected]>", "Oxc contributors"]
Expand Down
File renamed without changes.
24 changes: 0 additions & 24 deletions tasks/lint_rules/Cargo.toml

This file was deleted.

31 changes: 25 additions & 6 deletions tasks/lint_rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@ Task to update implementation progress for each linter plugin.

```sh
Usage:
$ cargo run <plugin_name> [--update]

Arguments:
plugin_name: Name of the target plugin
$ cmd [--target=<pluginName>]... [--update] [--help]

Options:
--update: Update GitHub issue comment
-h, --help: Show this message
--target, -t: Which plugin to target, multiple allowed
--update: Update the issue instead of printing to stdout
--help, -h: Print this help message
```

Environment variables `GITHUB_TOKEN` is required when `--update` is specified.

## Design

- Always install `eslint-plugin-XXX@latest` from npm
- Load them through ESLint Node.js API
- https://eslint.org/docs/latest/integrate/nodejs-api#linter
- List all their plugin rules(name, deprecated, recommended, docs, etc...)
- List all our implemented rules(name)
- Combine these lists and render as markdown
- Update GitHub issue body

## FAQ

- Why is this task written in Node.js? Why not Rust?
- Some plugins do not provide static rules list
- https://github.com/jest-community/eslint-plugin-jest/
- Easiest way to collect the list is just evaluating config file in JavaScript
- Why `.cjs`?
- To keep dependencies as simple as possible
- Some plugins only provide their module as CommonJS
- So, CommonJS is the only way to go without bundling
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "lint_rules2",
"name": "lint_rules",
"main": "./src/main.cjs",
"version": "0.0.0",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ exports.ALL_TARGET_PLUGINS = new Map([
["jsx-a11y", { npm: "eslint-plugin-jsx-a11y", issueNo: 1141 }],
["jest", { npm: "eslint-plugin-jest", issueNo: 492 }],
["react", { npm: "eslint-plugin-react", issueNo: 1022 }],
["react-hooks", { npm: "eslint-plugin-react-hooks", issueNo: -1 }], // TODO: Fill issueNo
["react-hooks", { npm: "eslint-plugin-react-hooks", issueNo: 2174 }],
["react-perf", { npm: "eslint-plugin-react-perf", issueNo: 2041 }],
["nextjs", { npm: "@next/eslint-plugin-next", issueNo: 1929 }],
]);
Expand Down
60 changes: 0 additions & 60 deletions tasks/lint_rules/src/generate_list/eslint.rs

This file was deleted.

75 changes: 0 additions & 75 deletions tasks/lint_rules/src/generate_list/mod.rs

This file was deleted.

67 changes: 0 additions & 67 deletions tasks/lint_rules/src/generate_list/typescript.rs

This file was deleted.

File renamed without changes.
Loading

0 comments on commit cba8a4c

Please sign in to comment.