Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f289660
feat: add bildFromOxlintConfig
Sysix Oct 24, 2024
c26022a
feat: add buildFromOxlintConfig
Sysix Oct 24, 2024
d43a81e
feat: add buildFromOxlintConfig
Sysix Oct 24, 2024
a021951
feat: add buildFromOxlintConfig
Sysix Oct 24, 2024
8890a8c
feat: add buildFromOxlintConfig
Sysix Oct 24, 2024
d65022a
feat: add buildFromOxlintConfig
Sysix Oct 25, 2024
5647f25
feat: add buildFromOxlintConfig
Sysix Oct 25, 2024
0cecffe
feat: add buildFromOxlintConfig
Sysix Oct 25, 2024
d3dc1fa
feat: add buildFromOxlintConfig
Sysix Oct 25, 2024
caf5f58
feat: add buildFromOxlintConfig
Sysix Oct 26, 2024
fe27e5d
feat: add buildFromOxlintConfig
Sysix Oct 27, 2024
dd6dc94
feat: add buildFromOxlintConfig
Sysix Oct 27, 2024
22f0166
feat: add buildFromOxlintConfig
Sysix Oct 27, 2024
b53ab00
feat: add buildFromOxlintConfig
Sysix Oct 27, 2024
33a1e3e
feat: add buildFromOxlintConfig
Sysix Oct 27, 2024
4455703
feat: add buildFromOxlintConfig
Sysix Oct 27, 2024
17101d0
feat: add buildFromOxlintConfig
Sysix Oct 28, 2024
06952e7
feat: add buildFromOxlintConfig
Sysix Oct 28, 2024
529857c
feat: add buildFromOxlintConfig - start prepare for overrides
Sysix Oct 28, 2024
d97bd45
Merge branch 'main' into feat-build-from-oxlint-config
Sysix Oct 29, 2024
786fce1
feat: add buildFromOxlintConfig
Sysix Oct 29, 2024
ae5ccbc
feat: add buildFromOxlintConfig
Sysix Oct 30, 2024
b1b3df5
feat: add buildFromOxlintConfig
Sysix Oct 30, 2024
4dab02f
feat: add buildFromOxlintConfig - downgrade rules to match current ve…
Sysix Oct 30, 2024
c9999dc
feat: add buildFromOxlintConfig
Sysix Oct 30, 2024
dfd914e
feat: add buildFromOxlintConfig
Sysix Oct 30, 2024
e300732
feat: add buildFromOxlintConfig
Sysix Oct 30, 2024
1d54fea
feat: add buildFromOxlintConfigFile
Sysix Oct 30, 2024
f4d943c
Revert "feat: add buildFromOxlintConfig - downgrade rules to match cu…
Sysix Oct 30, 2024
7fcf529
Merge branch 'main' into feat-build-from-oxlint-config
Sysix Oct 31, 2024
47b2307
feat: add buildFromOxlintConfigFile
Sysix Oct 31, 2024
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
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,39 @@ module.exports = {
}
```

### Detect rules from `oxlint.json`

If you are using flat configuration (eslint >= 9.0), you can use the following config:

```js
// eslint.config.js
import { buildFromOxlintConfigFile } from 'eslint-plugin-oxlint';
export default [
..., // other plugins
...buildFromOxlintConfigFile('./oxlint.json'),
];
```

Or build it by an `oxlint.json`-like object:

```js
// eslint.config.js
import { buildFromOxlintConfig } from 'eslint-plugin-oxlint';
export default [
..., // other plugins
...buildFromOxlintConfig({
categories: {
correctness: 'warn'
},
rules: {
eqeqeq: 'warn'
}
}),
];
```

`buildFromOxlintConfigFile` is not supported for legacy configuration (eslint < 9.0).

### Run it before eslint

And then you can add the following script to your `package.json`:
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,8 @@
},
"volta": {
"node": "20.14.0"
},
"dependencies": {
"jsonc-parser": "^3.3.1"
}
}
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions scripts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const ignoreScope = new Set(['oxc', 'deepscan', 'security']);
// only used for the scopes where the directory structure doesn't reflect the eslint scope
// such as `typescript` vs `@typescript-eslint` or others. Eslint as a scope is an exception,
// as eslint doesn't have a scope.
// There is a duplicate in src/build-from-oxlint-config.ts, for clean builds we manage it in 2 files.
// In the future we can generate maybe this constant into src folder
export const scopeMaps = {
eslint: '',
typescript: '@typescript-eslint',
Expand Down
187 changes: 187 additions & 0 deletions src/__snapshots__/build-from-oxlint-config.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`buildFromOxlintConfig > custom plugins, custom categories > customPluginCustomCategories 1`] = `
[
{
"name": "oxlint/from-oxlint-config",
"rules": {
"constructor-super": "off",
"getter-return": "off",
"import/export": "off",
"import/no-deprecated": "off",
"import/no-unused-modules": "off",
"no-undef": "off",
"no-unreachable": "off",
},
},
]
`;

exports[`buildFromOxlintConfig > custom plugins, default categories > customPluginDefaultCategories 1`] = `
[
{
"name": "oxlint/from-oxlint-config",
"rules": {
"for-direction": "off",
"no-async-promise-executor": "off",
"no-caller": "off",
"no-class-assign": "off",
"no-compare-neg-zero": "off",
"no-cond-assign": "off",
"no-const-assign": "off",
"no-constant-binary-expression": "off",
"no-constant-condition": "off",
"no-control-regex": "off",
"no-debugger": "off",
"no-delete-var": "off",
"no-dupe-class-members": "off",
"no-dupe-else-if": "off",
"no-dupe-keys": "off",
"no-duplicate-case": "off",
"no-empty-character-class": "off",
"no-empty-pattern": "off",
"no-empty-static-block": "off",
"no-ex-assign": "off",
"no-extra-boolean-cast": "off",
"no-func-assign": "off",
"no-global-assign": "off",
"no-import-assign": "off",
"no-invalid-regexp": "off",
"no-irregular-whitespace": "off",
"no-loss-of-precision": "off",
"no-new-native-nonconstructor": "off",
"no-nonoctal-decimal-escape": "off",
"no-obj-calls": "off",
"no-self-assign": "off",
"no-setter-return": "off",
"no-shadow-restricted-names": "off",
"no-sparse-arrays": "off",
"no-this-before-super": "off",
"no-unsafe-finally": "off",
"no-unsafe-negation": "off",
"no-unsafe-optional-chaining": "off",
"no-unused-labels": "off",
"no-unused-private-class-members": "off",
"no-unused-vars": "off",
"no-useless-catch": "off",
"no-useless-escape": "off",
"no-useless-rename": "off",
"no-with": "off",
"require-yield": "off",
"unicorn/no-await-in-promise-methods": "off",
"unicorn/no-document-cookie": "off",
"unicorn/no-empty-file": "off",
"unicorn/no-invalid-remove-event-listener": "off",
"unicorn/no-new-array": "off",
"unicorn/no-single-promise-in-promise-methods": "off",
"unicorn/no-thenable": "off",
"unicorn/no-unnecessary-await": "off",
"unicorn/no-useless-fallback-in-spread": "off",
"unicorn/no-useless-length-check": "off",
"unicorn/no-useless-spread": "off",
"unicorn/prefer-set-size": "off",
"unicorn/prefer-string-starts-ends-with": "off",
"use-isnan": "off",
"valid-typeof": "off",
},
},
]
`;

exports[`buildFromOxlintConfig > default plugins (react, unicorn, typescript), default categories > defaultPluginDefaultCategories 1`] = `
[
{
"name": "oxlint/from-oxlint-config",
"rules": {
"@typescript-eslint/no-dupe-class-members": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",
"@typescript-eslint/no-extra-non-null-assertion": "off",
"@typescript-eslint/no-loss-of-precision": "off",
"@typescript-eslint/no-misused-new": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-useless-empty-export": "off",
"@typescript-eslint/no-wrapper-object-types": "off",
"@typescript-eslint/prefer-as-const": "off",
"@typescript-eslint/triple-slash-reference": "off",
"for-direction": "off",
"no-async-promise-executor": "off",
"no-caller": "off",
"no-class-assign": "off",
"no-compare-neg-zero": "off",
"no-cond-assign": "off",
"no-const-assign": "off",
"no-constant-binary-expression": "off",
"no-constant-condition": "off",
"no-control-regex": "off",
"no-debugger": "off",
"no-delete-var": "off",
"no-dupe-class-members": "off",
"no-dupe-else-if": "off",
"no-dupe-keys": "off",
"no-duplicate-case": "off",
"no-empty-character-class": "off",
"no-empty-pattern": "off",
"no-empty-static-block": "off",
"no-ex-assign": "off",
"no-extra-boolean-cast": "off",
"no-func-assign": "off",
"no-global-assign": "off",
"no-import-assign": "off",
"no-invalid-regexp": "off",
"no-irregular-whitespace": "off",
"no-loss-of-precision": "off",
"no-new-native-nonconstructor": "off",
"no-nonoctal-decimal-escape": "off",
"no-obj-calls": "off",
"no-self-assign": "off",
"no-setter-return": "off",
"no-shadow-restricted-names": "off",
"no-sparse-arrays": "off",
"no-this-before-super": "off",
"no-unsafe-finally": "off",
"no-unsafe-negation": "off",
"no-unsafe-optional-chaining": "off",
"no-unused-labels": "off",
"no-unused-private-class-members": "off",
"no-unused-vars": "off",
"no-useless-catch": "off",
"no-useless-escape": "off",
"no-useless-rename": "off",
"no-with": "off",
"react/iframe-missing-sandbox": "off",
"react/jsx-key": "off",
"react/jsx-no-duplicate-props": "off",
"react/jsx-no-target-blank": "off",
"react/jsx-no-undef": "off",
"react/jsx-props-no-spread-multi": "off",
"react/no-children-prop": "off",
"react/no-danger-with-children": "off",
"react/no-direct-mutation-state": "off",
"react/no-find-dom-node": "off",
"react/no-is-mounted": "off",
"react/no-render-return-value": "off",
"react/no-string-refs": "off",
"react/void-dom-elements-no-children": "off",
"require-yield": "off",
"unicorn/no-await-in-promise-methods": "off",
"unicorn/no-document-cookie": "off",
"unicorn/no-empty-file": "off",
"unicorn/no-invalid-remove-event-listener": "off",
"unicorn/no-new-array": "off",
"unicorn/no-single-promise-in-promise-methods": "off",
"unicorn/no-thenable": "off",
"unicorn/no-unnecessary-await": "off",
"unicorn/no-useless-fallback-in-spread": "off",
"unicorn/no-useless-length-check": "off",
"unicorn/no-useless-spread": "off",
"unicorn/prefer-set-size": "off",
"unicorn/prefer-string-starts-ends-with": "off",
"use-isnan": "off",
"valid-typeof": "off",
},
},
]
`;
Loading