Skip to content

Commit

Permalink
feat: add buildFromOxlintConfig - start prepare for overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix committed Oct 28, 2024
1 parent 06952e7 commit 529857c
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 153 deletions.
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,17 @@ If you are using flat configuration (eslint >= 9.0), you can use the following c
// eslint.config.js
import { buildFromOxlintConfigFile } from 'eslint-plugin-oxlint';
export default [
...// other plugins
{
// oxlint should be the last one
name: 'oxc/custom',
rules: buildFromOxlintConfigFile('./oxlint.json'),
},
..., // other plugins
...buildFromOxlintConfigFile('./oxlint.json'),
];
```

If you are using legacy configuration (eslint < 9.0), you can use the following config:

```js
import { buildFromOxlintConfigFile } from 'eslint-plugin-oxlint';
const { buildFromOxlintConfigFile } = require('eslint-plugin-oxlint');

// .eslintrc.js
module.exports = {
... // other config
rules: {
... // other rules
...buildFromOxlintConfigFile('./oxlint.json'),
},
}
// TODO
```

### Run it before eslint
Expand Down
247 changes: 131 additions & 116 deletions src/__snapshots__/build-from-oxlint-config.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,126 +1,141 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`buildFromOxlintConfig > custom plugins, custom categories > customPluginCustomCategories 1`] = `
{
"constructor-super": "off",
"getter-return": "off",
"import/export": "off",
"import/no-deprecated": "off",
"import/no-unused-modules": "off",
"no-undef": "off",
"no-unreachable": "off",
}
[
{
"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`] = `
{
"no-async-promise-executor": "off",
"no-caller": "off",
"no-class-assign": "off",
"no-cond-assign": "off",
"no-const-assign": "off",
"no-constant-binary-expression": "off",
"no-constant-condition": "off",
"no-control-regex": "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-ex-assign": "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-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-optional-chaining": "off",
"no-unused-private-class-members": "off",
"no-useless-catch": "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-thenable": "off",
}
[
{
"name": "oxlint/from-oxlint-config",
"rules": {
"no-async-promise-executor": "off",
"no-caller": "off",
"no-class-assign": "off",
"no-cond-assign": "off",
"no-const-assign": "off",
"no-constant-binary-expression": "off",
"no-constant-condition": "off",
"no-control-regex": "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-ex-assign": "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-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-optional-chaining": "off",
"no-unused-private-class-members": "off",
"no-useless-catch": "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-thenable": "off",
},
},
]
`;

exports[`buildFromOxlintConfig > default plugins (react, unicorn, typescript), default categories > defaultPluginDefaultCategories 1`] = `
{
"@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/triple-slash-reference": "off",
"no-async-promise-executor": "off",
"no-caller": "off",
"no-class-assign": "off",
"no-cond-assign": "off",
"no-const-assign": "off",
"no-constant-binary-expression": "off",
"no-constant-condition": "off",
"no-control-regex": "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-ex-assign": "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-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-optional-chaining": "off",
"no-unused-private-class-members": "off",
"no-useless-catch": "off",
"no-useless-rename": "off",
"no-with": "off",
"react/jsx-key": "off",
"react/jsx-no-duplicate-props": "off",
"react/jsx-no-target-blank": "off",
"react/jsx-no-undef": "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-thenable": "off",
}
[
{
"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/triple-slash-reference": "off",
"no-async-promise-executor": "off",
"no-caller": "off",
"no-class-assign": "off",
"no-cond-assign": "off",
"no-const-assign": "off",
"no-constant-binary-expression": "off",
"no-constant-condition": "off",
"no-control-regex": "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-ex-assign": "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-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-optional-chaining": "off",
"no-unused-private-class-members": "off",
"no-useless-catch": "off",
"no-useless-rename": "off",
"no-with": "off",
"react/jsx-key": "off",
"react/jsx-no-duplicate-props": "off",
"react/jsx-no-target-blank": "off",
"react/jsx-no-undef": "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-thenable": "off",
},
},
]
`;
Loading

0 comments on commit 529857c

Please sign in to comment.