Commit graph

165 commits

Author SHA1 Message Date
Yuji Sugiura
ba2121f17d
feat(linter): Add --jsdoc-plugin flag (#2935)
Add flag to:

```sh
$ oxlint --jsdoc-plugin
```


![image](https://github.com/oxc-project/oxc/assets/6259812/0e12ceab-966f-47e1-b4b9-5bc2eb6bdb56)
2024-04-12 10:39:12 +08:00
Boshen
c250b288ef
fix(cli): return error if --format receives an unknown value 2024-04-11 21:38:39 +08:00
Boshen
98bf7e6767
fix(cli): fix oxlint --format json yields 0 files to lint (#2940)
closes #2930
2024-04-11 16:03:31 +08:00
Kalven Schraut
6eba02f472
fix(cli): if format is json do not print summary information (#2899) (#2925)
this allows the ability to redirect the stdout to so can create a valid
json file

this also matches with eslint's format option

closes #2899
2024-04-09 14:26:10 +08:00
Boshen
d63127d009
chore: only build the allocators in release mode because they are slow to build (60s) 2024-04-02 17:39:01 +08:00
Dunqing
23651980d1
feat(cli): add tsconfig file validation in LintRunner (#2850) 2024-03-29 19:56:30 +08:00
Andi Pabst
4c5abb590e
feat(cli): wildcard expansion in paths for windows (#2767)
Unlike on other OS, on Windows there is no wildcard expansion/globbing
by the shell. Instead the application has to handle this. Therefore I
used the `glob` package to handle wildcards on Windows.

I also had to make the parent directory check more strict due to the
glob package resolving `..` in the middle of the path as well.

This closes #2695.
2024-03-22 00:21:30 +08:00
Boshen
0f86333437
refactor(ast): refactor Trivias API - have less noise around it (#2692) 2024-03-12 20:16:36 +08:00
Boshen
c72675e89e
chore: Rust v1.76.0 (#2643) 2024-03-08 20:54:36 +08:00
Boshen
02c82c3f78
feat(cli,linter): provide tsconfig path from the cli (#2526)
closes #891
2024-02-27 20:00:11 +08:00
Boshen
d0d0d9d7bb
feat(diagnostics): implement json reporter (#2452) 2024-02-20 15:33:28 +08:00
Boshen
195d76e6a5
feat(cli,diagnostics): add json reporter (#2451) 2024-02-20 15:28:27 +08:00
Boshen
399c3a6234
feat(cli): add --format option (#2450) 2024-02-20 15:23:37 +08:00
Boshen
9cfc97c30d
refactor(cli): move --rules into LintOptions (#2449) 2024-02-20 12:59:07 +08:00
Boshen
fca6e02f84
refactor(cli): remove the codeowners feature (#2448)
I should've done a better job at selecting features. Every feature
requires more than just code to get it right.

linting by codeowners' files sounds good on paper but actually not that
useful.
2024-02-20 12:54:16 +08:00
Boshen
6b18b7c198
refactor(cli): split the command files (#2447) 2024-02-20 12:43:13 +08:00
Boshen
ab8a3114a2
feat(cli): add --version (#2182)
closes #2154
2024-01-26 19:13:17 +08:00
fi3ework
ee5b9682ae
feat(linter): support read env from eslintrc (#2130)
## target

resolve #732 

## contexts

- globals definition from
https://github.com/sindresorhus/globals/blob/main/globals.json
- port https://github.com/eslint/eslintrc/blob/main/conf/environments.js
to derive environments
2024-01-26 10:43:44 +08:00
Boshen
a978639718
feat(cli): disallow path pointing to parent directories (#2125)
Linting parent directories introduces undefined behavior because
the intention is not clear. This is a future proof precaution.

closes #1887
2024-01-22 17:52:57 +08:00
Hulk
20a34b5294
feat: introduce --react-perf-plugin CLI flag, update rules to correctness (#2119)
https://github.com/oxc-project/oxc/issues/2041#issuecomment-1903316240

Closes #2041
2024-01-22 16:45:32 +08:00
Boshen
9e06bd7797
feat(linter): remove the --timings feature (#2049)
For a various reasons:

This features bloats the code size.

We have many tools for profiling in Rust (as compared to ESLint where the feature came from),
so a built-in feature is not really needed anymore.

ESLint needed `--timings` because it needs to monitor plugins.
We control all our code so we don't need this.
2024-01-16 14:21:04 +08:00
Boshen
f4132976e9
chore: say good bye to ezno (#2048)
ezno has decided to focus on its own compiler for 2024,
we part away but we still collaborate and share knowledge together.
2024-01-16 13:53:54 +08:00
Boshen
68606c4d6d
fix(linter): keep rules disabled if the rule is not enabled in the config (#2031)
relates #1969
2024-01-15 05:32:51 +00:00
Boshen
fb5d0a740c
feat(linter): add support for same rule name but different plugin names (#1992)
e.g.

```
{
  "rules": {
    "semi": "off",
    "@typescript-eslint/semi": "error"
  }
}
```

closes #1975
2024-01-11 18:05:05 +08:00
fi3ework
e0da12a868
fix(linter): allow eslintrc to add rule when overriding (#1984)
Fix a bug introduced in https://github.com/oxc-project/oxc/pull/1966.
Ideally, the rules in eslintrc should be merged into final rules as
described:

> The rules will start with the categories we apply, and then merge all
the configurations stated in the rules field.
>
> For example, if we begin with -D correctness with 80 rules, then
>
> "no-empty-file": "off" will remove the rule, yielding 79 rules
> "no-empty": "error" (restriction) will add the rule, yield 81 rules
> ""no-empty": ["error", { "allowEmptyCatch": true }]` add the rule's
configuration

However, the implementation did not include the newly added rules in the
eslintrc. As a test case and example, I added a new fixture to
`crates/oxc_cli/fixtures/no_undef`. No warn or deny will be found
without this PR.

This is my first Rust PR ever. Any nitpicking suggestions are welcome.
Thanks! 😊
2024-01-11 11:43:02 +08:00
Boshen
856b9a59eb
feat(linter): support overriding oxlint rules by eslint config (#1966)
Previously if .eslintrc.json contains 

```
{
  "rules": {
    "no-empty": "off"
  }
}
```

Then no rules will be enabled.

---

This PR changes how we configure oxlint's rules.

The rules will start with the categories we apply, and then merge all
the configurations stated in the `rules` field.

For example, if we begin with `-D correctness` with 80 rules, then

* `"no-empty-file": "off"` will remove the rule, yielding 79 rules
* `"no-empty": "error"` (restriction) will add the rule, yield 81 rules
* ""no-empty": ["error", { "allowEmptyCatch": true }]` add the rule's
configuration
2024-01-10 15:44:53 +08:00
Cameron
ac3b44bd0c
feat: nextjs plugin (#1948)
https://github.com/oxc-project/oxc/issues/1929#issuecomment-1880369624
2024-01-09 11:08:11 +08:00
Boshen
f2ed83ca3b
feat(linter): <script> part of svelte file (#1918)
closes #1914
2024-01-07 00:13:44 +08:00
Boshen
72615877dc
feat(linter): allow "-c" configuration (#1909)
closes #1693
2024-01-06 16:32:11 +08:00
Boshen
497a20796c
feat(linter): parse two script tags from vue (#1899) 2024-01-05 16:44:27 +08:00
Boshen
8a3eff1bee
feat(linter): parse multiple script tags in astro file (#1898) 2024-01-05 16:36:31 +08:00
Boshen
a63490c1c0
feat(linter): support astro front matter --- block (#1893)
closes #1702
2024-01-05 10:05:43 +08:00
Boshen
11ca5c2bad
feat(linter): do not lint when vue file has no js section (#1891) 2024-01-04 21:24:19 +08:00
Boshen
5b652fe1db
refactor(cli): improve the code around lint-staged handling (#1889) 2024-01-04 20:50:59 +08:00
Clark Fischer
d88d76fdb8
Prioritize ignored paths when linting (#1878)
As discussed in #1124

A common workflow is running `oxlint` automatically via something like
lint-staged, which passes all changed file paths explicitly as CLI
arguments. The ignore crate auto-whitelists explicit paths, overriding
anything defined in an ignore file, leading to files that should be
ignored causing CI and VC hooks to fail.

eslint avoids this issue by giving precedence to .eslintignore unless
you pass `--no-ignore`.

Since `ignore` doesn't really give much control over this, the most
effective solution seems to be filtering. ~~Once we've got a list of
files to be linted, we can compare each against the .eslintignore and
see if it really truly should be linted.~~

~~Unfortunately, this is sort of a naive solution. Ignored directories
will still be walked, then filtered out after the fact. Changing this
behavior at the walker level would affect the formatter, which probably
isn't desirable.~~ (edit: The performance impact has been mostly
resolved.)

Signed-off-by: Clark Fischer <clark.fischer@gmail.com>
2024-01-04 03:44:10 +00:00
Wenzhe Wang
ec9598cefc
test(cli): add simple integration test for vue file (#1863) 2023-12-31 22:37:26 +08:00
Wenzhe Wang
8f27a98468
feat(cli): support walk vue and astro (#1745) 2023-12-31 22:15:11 +08:00
Cameron
df29e8da72
fix(cli) skip run lint when --rules is passed (#1747)
not sure if there is a cleaner way to do this.

maybe change `check_options` to return an Option - none if no CliResult, Some if there is a cli result (something was incorrect or the cmd was handled)
2023-12-20 12:24:45 +08:00
Cameron
4ebb3fb218
fix(cli): conflict between --import-plugin and -D correctness (#1729)
closes #1727
2023-12-18 21:20:48 +08:00
Cameron
9275c749ca
feat(linter) Parse eslint configuration (#1146)
**DRAFT**

Adds support for parsing `eslint` configuration files.

Example: 
```sh
cargo run --bin=oxc_cli lint --config-path ./.eslintrc.json .
```

This isn't a full implementation of how eslint parses configs but should
be fine for now:

Currently supported `extends`:
 - `eslint:recommended` -> `eslint`
 - `plugin:react/recommended` -> `react`
 - `plugin:@typescript-eslint/recommended` -> `typescript`
 - `plugin:react-hooks/recommended` -> `react`
 - `plugin:unicorn/recommended` -> `unicorn`
 - `plugin:jest/recommended` -> `jest`

These defaults can _all_ be overridden by configuring the rule in the
`rules` section of the estlint config:

e.g.
```json
{
    "extends": [
        "eslint:recommended"
    ],
    "rules": {
        "eqeqeq": "off"
    },
}
```

This would enable of of the rules within the `eslint` group. But would
not enable `eqeqeq` as it is explicitly disabled

Note, we do not currently support the following:
 - supplying a `filter` and `config-path`
 - supplying a `plugin` and `config-path`
2023-12-14 16:29:27 +08:00
Boshen
064353c97e
feat(prettier): turn off preserve_parens and start working on need-parens (#1487) 2023-11-21 16:26:56 +00:00
Shannon Rothe
0b6b0b4854
feat(cli): add --deny-warnings flag (#1452)
See #1403

Terminates linting with an exit code of 1 if the `--deny-warnings` flag
is provided _and_ there is 1 or more warnings produced from the linting.
2023-11-21 10:08:10 +08:00
Boshen
5f316626f6
feat(prettier): add the basics of comment printing (#1313) 2023-11-14 12:32:03 +00:00
Boshen
4977ea1554
feat(cli): add basic prettier cli infrastructure (#1300) 2023-11-14 08:22:22 +00:00
Boshen
d82ba5b523
feat(cli): run oxlint with no file arguments (#1201)
closes #1190

See: `https://github.com/eslint/eslint/issues/14308`
2023-11-09 11:22:13 +08:00
Wenzhe Wang
c7598b22ff
chore(cli): move import_plugin into enable_plugins (#1158) 2023-11-06 09:00:36 +08:00
Wenzhe Wang
4e9260ec03
feat: basic enable plugin (#1154) 2023-11-05 21:46:30 +08:00
Boshen
6da5a3f216
feat(cli): print execution time in seconds when greater than 1 second (#1107) 2023-10-30 16:35:40 +08:00
Boshen
4e218331c2
refactor(cli): clean up code around codeowners (#1099) 2023-10-30 11:21:41 +08:00
u9g
1704a76f6f
Codeowners filtering (#1083)
closes #1066
2023-10-29 13:30:20 +08:00