Commit graph

1560 commits

Author SHA1 Message Date
Dunqing
edc6fa4830
feat(semantic): add SymbolFlags::Function for FunctionDeclaration (#1713)
Co-authored-by: Boshen <boshenc@gmail.com>
2023-12-18 11:26:33 +08:00
msdlisper
8f296dfb7a
refactor(linter): use fxHashMap in jsx-a11y settings (#1707)
Continue to refine #1668
2023-12-17 20:05:21 +08:00
Ken-HH24
774a257a66
feat(linter): eslint-plugin-unicorn no-null(style) (#1705)
Try to implement
[no-null](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-null.md)
for #684 .
2023-12-17 10:24:09 +00:00
Cameron
f4f0bdf74a
chore(linter) convert catch error name to a warning (#1700) 2023-12-16 17:52:26 +00:00
Cameron
c61ea76b73
fix(linter) improve diagnostic for no useless spread (#1698)
closes #1697
2023-12-16 17:47:55 +00:00
Cameron
73a655f5b5
fix(linter) remove parsing of extends eslint config (#1695)
See https://github.com/oxc-project/oxc/issues/1672

we can bring this back (or a version of it) once we work out how we
want`extends` to work.
2023-12-16 12:46:27 +00:00
msdlisper
6a90cd4af4
feat(linter): add jsx-a11y settings (#1668)
When we developed linter for #1141 , we needed to configure some
settings for `jsx-a11y`, which was not supported before, but I am trying
to support it now.
like this:
```
fn config() -> serde_json::Value {
    serde_json::json!([2,{
        "ignoreNonDOM": true
    }])
}

fn settings() -> serde_json::Value {
    serde_json::json!({
        "jsx-a11y": {
            "components": {
                "Button": "button",
            }
        }
    })
}

let pass = vec![
    ("<Button />", Some(config()), Some(settings())),
];
```
2023-12-16 13:45:14 +08:00
Cameron
6268f3f2f4
fix(linter) Fix false positives in prefer string start, ends with, port more test cases (#1689)
closes #1687 - uses `intersection` instead of `||`:
 - this improves performance as it combines the flags into a single bitmask instead of doing two seperate checks
 - 

Adds missing test cases from eslint-plugin-unicorn
2023-12-15 17:08:42 +00:00
Andy Armstrong
d101acf833
fix(linter): prefer-string-starts-ends-with: ignore i and m modifiers. (#1688)
Fixes: #1687
2023-12-15 17:00:43 +00:00
Cameron
9f990ce677
fix(linter) false positive in jsx key (#1686) 2023-12-15 22:25:14 +08:00
Cameron
0d7e166f4b
refactor: use new_without_config for jsx_key (#1685) 2023-12-15 11:40:07 +00:00
Cameron
0a8746c751
fix(linter): Panic in prefer string starts, ends with (#1684)
Closes #1683
2023-12-15 11:35:01 +00:00
yoshi2no
cf0793b675
feat(linter): tabindex-no-positive for eslint-plugin-jsx-a11y (#1677)
partof: #1141

I've implemented `tabindex-no-positive` rule for jsx_a11y

originals:

- doc:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/tabindex-no-positive.md
- code:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/tabindex-no-positive.js
- test:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__tests__/src/rules/tabindex-no-positive-test.js
2023-12-15 11:17:38 +08:00
RiESAEX
e5752a5462
fix(linter): fix excape_case panicing on unicode strings (#1673)
fix: #1671
2023-12-14 20:32:16 +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
Hao Cheng
c9589b5447
feat(linter): eslint-plugin-unicorn/prefer-prototype-methods (#1660) 2023-12-14 14:55:03 +08:00
Boshen
8edcab82f2
chore(lexer): document the accessor keyword 2023-12-14 12:55:55 +08:00
Wenzhe Wang
d719af473c
refactor(linter): make some jest rules report more detailed (#1666) 2023-12-14 11:05:06 +08:00
Wenzhe Wang
90524c83f7
feat(linter): add eslint-plugin-import(export) rule (#1654) 2023-12-13 23:12:45 +08:00
Wenzhe Wang
c49a1f6b32
feat(prettier): add print_binaryish_expressions (#1664) 2023-12-13 22:52:53 +08:00
Dunqing
f58b6279c8
feat(transformer): add arrow_functions plugin (#1663) 2023-12-13 20:46:28 +08:00
Dunqing
67b7cc0f51
feat(ast): support visit more jsx ast in visit (#1662) 2023-12-13 20:41:44 +08:00
Ken-HH24
282771afc4
feat(linter): eslint-plugin-unicorn prefer-dom-node-text-content(style) (#1658)
Implement [prefer-dom-node-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-text-content.md) for #684 .
2023-12-13 12:19:00 +00:00
Dunqing
00806384ff
perf(linter/react): find class node by symbols in get_parent_es6_component (#1657)
This way we can get the class node faster. But I don't know if this is a
good way. In `eslint-plugin-react`, they get class node by scope. But
oxc cannot do the same way
2023-12-13 13:48:53 +08:00
Dunqing
864176a051
feat(transformer/react-jsx): returns ThisExpression when identifier is this (#1661) 2023-12-13 13:47:54 +08:00
Boshen
4ced3f949c
refactor(linter): separate out the category in the output of --rules 2023-12-13 13:23:52 +08:00
Boshen
ca009d5995
chore(linter): move prefer-array-flat to pedantic 2023-12-13 13:16:18 +08:00
Boshen
117d95f0ae
fix(linter): improve the span message for no-accumulating-spread 2023-12-12 16:28:37 +08:00
dependabot[bot]
a3b52fb548
chore(deps): bump the dependencies group with 7 updates (#1651) 2023-12-11 14:21:56 +08:00
Boshen
69c056be79
chore: remove crates/oxc_parser/README.md 2023-12-11 13:59:03 +08:00
Cameron
295822d7d4
feat(linter) eslint plugin unicorn: prefer array flat (#1650) 2023-12-10 23:19:30 +08:00
Cameron
ef740c3754
fix: improve span for no accumulating spread (#1644)
Closes #1643
2023-12-10 23:18:39 +08:00
Ken-HH24
e331cc2677
feat(transformer): duplicate keys (#1649) 2023-12-10 18:07:32 +08:00
Cameron
65c07728fc
fix: remove escapes in no array reduce test cases (#1647) 2023-12-10 09:42:40 +00:00
Cameron
a09060be33
fix: remove escapes in prefer regexp test test cases (#1645) 2023-12-10 09:37:41 +00:00
Cameron
9bea2780d9
feat(linter) eslint-plugin-react: react-in-jsx-scope (#1025)
Co-authored-by: wenzhe <mysteryven@gmail.com>
2023-12-10 17:08:43 +08:00
Ken-HH24
b425b73087
feat(linter): eslint-plugin-unicorn prefer-modern-dom-apis(style) (#1646) 2023-12-10 16:10:59 +08:00
Dunqing
0c19991471
feat(prettier): print CallExpression arguments correctly (#1631) 2023-12-10 15:59:13 +08:00
Boshen
b973261e5c
fix(linter): improve the key span for jsx-key 2023-12-08 17:40:35 +08:00
Boshen
8347e2225c
Release crates v0.4.0 2023-12-08 17:20:37 +08:00
Boshen
7ebe81d7ba
chore(linter): clean up the files a little bit 2023-12-08 16:50:06 +08:00
msdlisper
d88f4f4983
feat(linter): eslint-plugin-jsx-a11y no-autofocus (#1641)
impl linter for #1141
2023-12-08 16:43:14 +08:00
Dunqing
6e5aad2639
feat(prettier): add ConditionalGroup command (#1635) 2023-12-07 20:12:45 +08:00
Cameron
86fe7e3a3d
feat(linter) eslint plugin unicorn: no useless spread (#1638) 2023-12-07 17:31:22 +08:00
Wenzhe Wang
0dec110790
refactor(prettier): move the format of Function's key to PropertyKey (#1639) 2023-12-07 17:30:48 +08:00
Miles Johnson
c6ad6603a4
feat(semantic): support scope descendents starting from a certain scope. (#1629)
@Boshen 

The `ScopeTree.descendants` function would return all scopes starting
from the root, and wasn't truly descendants from a specific scope. To
improve this, I've renamed this function to `descendants_from_root` and
have introduced a new `descendants` function that does support from a
specific scope.

Furthermore, I've introduced helper functions to `SymbolTree` to make
reading symbols/scopes easier.

To verify this functionality, I enabled the `function_name` transformer
(and fixed it), and ran some example transforms. Here's the input:

```js
let fn;

fn = function (a, b, c) {
  const d = "";
};

const func = function (arg) {
  {
    const value = "";
  }
};

const f = function (f) {};
```

And the output using _the old implementation_. Note that all function
names are suffixed with a number, this is incorrect, since it was
inheriting far too many scopes.

```js
let fn;
fn = function fn1(a, b, c) {
	const d = '';
};
const func = function func1(arg) {
	{
		const value = '';
	}
};
const f = function f2(f) {
};
```

And here's the output with the new implementation. Note that only `f` is
suffixed with a number. That's because it has a shadowed argument of the
same name.

```js
let fn;
fn = function fn(a, b, c) {
	const d = '';
};
const func = function func(arg) {
	{
		const value = '';
	}
};
const f = function f1(f) {
};
```
2023-12-07 17:29:11 +08:00
Boshen
be731fe90c
chore: move oxc_resolver to https://github.com/oxc-project/oxc_resolver (#1636)
It is moved to https://github.com/oxc-project/oxc_resolver
2023-12-06 18:52:59 +08:00
Shinobu Hayashi
ddb3c62b87
feat(linter): eslint-plugin-jsx-a11y scope rule (correctness) (#1609)
## Summary

partof: #1141

I re-implemented scope rule for jsx_a11y in Rust same as the original JS
one, and moved also the test related to the rule to here.

originals:
- doc:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/scope.md
- code:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/scope.js
- test:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__tests__/src/rules/scope-test.js
2023-12-06 18:24:29 +08:00
Boshen
2e42e10a1b
feat(resolver): add a realpath to package.json (#1634)
Using the `realpath` for resolving browser field will lead to missing
queries.

This fixes a cases where `browserField` fails to read.

---

`styled-components` is using a trick for loading browser modules:

---

7c065e0b6f/packages/styled-components/package.json (L6C1-L12C5)

```json
  "main": "dist/styled-components.cjs.js",
  "module": "./dist/styled-components.esm.js",
  "browser": {
    "./dist/styled-components.esm.js": "./dist/styled-components.browser.esm.js",
    "./dist/styled-components.cjs.js": "./dist/styled-components.browser.cjs.js"
  },
```

Module resolution has to go from `"module":
"./dist/styled-components.esm.js"`, then to `browser`'s
`"./dist/styled-components.esm.js":
"./dist/styled-components.browser.esm.js"` part in order for things to
get resolved correctly.

---

Fixtures are hard to setup for this test case due to needing symlinks,
I've created https://github.com/oxc-project/oxc_resolver for tacking
such cases.
2023-12-06 12:25:44 +08:00
Wenzhe Wang
286644714f
feat(prettier): wrap parameters in indent (#1633) 2023-12-06 10:20:31 +08:00