fix(lint): align eslint and oxlint rules (#8118)
* docs: 路由文档示例代码同步路由组织新规范 * fix(lint): align eslint and oxlint rules * fix(lint): avoid control character regex
This commit is contained in:
@@ -16,6 +16,7 @@ const rulesCoveredByOxlint = new Set([
|
||||
'no-const-assign',
|
||||
'no-constant-binary-expression',
|
||||
'no-constant-condition',
|
||||
'no-control-regex',
|
||||
'no-debugger',
|
||||
'no-delete-var',
|
||||
'no-dupe-args',
|
||||
@@ -48,6 +49,8 @@ const rulesCoveredByOxlint = new Set([
|
||||
'no-shadow-restricted-names',
|
||||
'no-sparse-arrays',
|
||||
'no-this-before-super',
|
||||
'no-unassigned-vars',
|
||||
'no-unexpected-multiline',
|
||||
'no-unreachable',
|
||||
'no-unsafe-finally',
|
||||
'no-unsafe-negation',
|
||||
@@ -59,6 +62,7 @@ const rulesCoveredByOxlint = new Set([
|
||||
'no-useless-catch',
|
||||
'no-useless-escape',
|
||||
'no-with',
|
||||
'preserve-caught-error',
|
||||
'require-yield',
|
||||
'use-isnan',
|
||||
'valid-typeof',
|
||||
@@ -102,7 +106,6 @@ export async function javascript(): Promise<Linter.Config[]> {
|
||||
...recommendedRules,
|
||||
'dot-notation': ['error', { allowKeywords: true }],
|
||||
'keyword-spacing': 'off',
|
||||
'no-control-regex': 'error',
|
||||
'no-empty-function': 'off',
|
||||
'no-octal': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
|
||||
@@ -41,7 +41,7 @@ const javascript: OxlintConfig = {
|
||||
'no-caller': 'error',
|
||||
'no-case-declarations': 'error',
|
||||
'no-console': ['error', { allow: ['warn', 'error'] }],
|
||||
'no-control-regex': 'off',
|
||||
'no-control-regex': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||
'no-fallthrough': 'error',
|
||||
@@ -68,6 +68,8 @@ const javascript: OxlintConfig = {
|
||||
],
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'no-unassigned-vars': 'error',
|
||||
'no-unexpected-multiline': 'error',
|
||||
'no-unused-expressions': [
|
||||
'error',
|
||||
{
|
||||
@@ -108,6 +110,12 @@ const javascript: OxlintConfig = {
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'prefer-template': 'error',
|
||||
'preserve-caught-error': [
|
||||
'error',
|
||||
{
|
||||
requireCatchParameter: false,
|
||||
},
|
||||
],
|
||||
'symbol-description': 'error',
|
||||
'unicode-bom': ['error', 'never'],
|
||||
'use-isnan': [
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { OxlintConfig } from 'oxlint';
|
||||
|
||||
const vue: OxlintConfig = {
|
||||
rules: {
|
||||
'vue/no-reserved-component-names': 'off',
|
||||
'vue/prefer-import-from-vue': 'error',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -20,7 +20,13 @@ async function getStagedFiles(): Promise<string[]> {
|
||||
'-z',
|
||||
]);
|
||||
|
||||
let changedList = stdout ? stdout.replace(/\0$/, '').split('\0') : [];
|
||||
const nullSeparator = '\u0000';
|
||||
const normalizedStdout = stdout.endsWith(nullSeparator)
|
||||
? stdout.slice(0, -1)
|
||||
: stdout;
|
||||
let changedList = normalizedStdout
|
||||
? normalizedStdout.split(nullSeparator)
|
||||
: [];
|
||||
changedList = changedList.map((item) => path.resolve(process.cwd(), item));
|
||||
const changedSet = new Set(changedList);
|
||||
changedSet.delete('');
|
||||
|
||||
Reference in New Issue
Block a user