mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
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> {
|
|
return Object.keys(obj).sort().reduce(
|
|
(acc, key) => {
|
|
acc[key] = obj[key];
|
|
return acc;
|
|
},
|
|
) as any;
|
|
}
|
|
|
|
// 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));
|