mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
workspace: add oxlint
This commit is contained in:
18 files changed
+120
-44
No files matched your search
@@ -0,0 +1,72 @@
|
||||
import fs from 'fs';
|
||||
import { rules as baseBestPracticesRules } from 'eslint-config-airbnb-base/rules/best-practices';
|
||||
import { rules as baseErrorsRules } from 'eslint-config-airbnb-base/rules/errors';
|
||||
import { rules as baseES6Rules } from 'eslint-config-airbnb-base/rules/es6';
|
||||
import { rules as baseStyleRules } from 'eslint-config-airbnb-base/rules/style';
|
||||
import { rules as baseVariablesRules } from 'eslint-config-airbnb-base/rules/variables';
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
const base = yaml.load(fs.readFileSync('base.yaml', 'utf8')) as any;
|
||||
const react = yaml.load(fs.readFileSync('react.yaml', 'utf8')) as any;
|
||||
|
||||
function sort<T>(obj: Record<string, T>): Record<string, T> {
|
||||
const clone = { ...obj };
|
||||
Object.keys(clone).sort().reduce(
|
||||
(acc, key) => {
|
||||
acc[key] = clone[key];
|
||||
return acc;
|
||||
},
|
||||
);
|
||||
return clone;
|
||||
}
|
||||
|
||||
// NOTE: oxlint doesn't support most stylistic rules
|
||||
|
||||
const rules = sort({
|
||||
...baseBestPracticesRules,
|
||||
...baseErrorsRules,
|
||||
...baseES6Rules,
|
||||
...baseStyleRules,
|
||||
...baseVariablesRules,
|
||||
...base.rules,
|
||||
...react.rules,
|
||||
'no-unused-vars': [
|
||||
'off',
|
||||
// 'error',
|
||||
// {
|
||||
// caughtErrorsIgnorePattern: '^_|e',
|
||||
// argsIgnorePattern: '^_',
|
||||
// },
|
||||
],
|
||||
|
||||
'no-await-in-loop': 'off', // temporary disable the file until oxlint support extending config
|
||||
|
||||
// Let typescript to the thing
|
||||
'no-undef': 'off',
|
||||
'no-empty-function': 'off',
|
||||
'no-lonely-if': 'off',
|
||||
'no-unsafe-declaration-merging': 'off',
|
||||
'no-this-alias': 'off',
|
||||
'no-new-array': 'off', // It breaks [...new Array(n)].map()
|
||||
'no-useless-spread': 'off', // It breaks [...new Array(n)].map()
|
||||
'no-script-url': 'off', // It breaks createElement('a').setAttribute('href', 'javascript:;')
|
||||
});
|
||||
|
||||
delete rules['@typescript-eslint/no-unused-vars'];
|
||||
|
||||
fs.writeFileSync('.oxlintrc.json', JSON.stringify({
|
||||
$schema: './node_modules/oxlint/configuration_schema.json',
|
||||
rules,
|
||||
env: {
|
||||
browser: true,
|
||||
es6: true,
|
||||
jquery: true,
|
||||
node: true,
|
||||
},
|
||||
globals: {
|
||||
UiContext: 'readonly',
|
||||
UserContext: 'readonly',
|
||||
externalModules: 'readonly',
|
||||
LOCALES: 'readonly',
|
||||
},
|
||||
}, null, 2));
|
||||
Reference in new issue
Block a user