Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable @typescript-eslint/no-require-imports */
import fs from 'fs';
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
if (ruleValue.meta.deprecated) {
deprecatedRules.push(fullRuleName);
return;
}
/* eslint-disable @typescript-eslint/no-require-imports */
/**
* 批量删除 eslint-config-prettier 中的规则
*/
import fs from 'fs';
import path from 'path';
import rimraf from 'rimraf';
const prettier = require('eslint-config-prettier');
const prettierReact = require('eslint-config-prettier/react');
const prettierVue = require('eslint-config-prettier/vue');
const prettierTypeScript = require('eslint-config-prettier/@typescript-eslint');
const prettierRules = {
index: prettier.rules,
react: prettierReact.rules,
vue: prettierVue.rules,
typescript: prettierTypeScript.rules
};
const RULE_PREFIX_MAP = {
index: '',
react: 'react/',
vue: 'vue/',
typescript: '@typescript-eslint/'
};
type RulePrefix = keyof typeof RULE_PREFIX_MAP;
const namespaces: RulePrefix[] = ['index', 'react', 'vue', 'typescript'];
namespaces.forEach((namespace) => {
fs.readdirSync(path.resolve(__dirname, '../test', namespace))
.filter((ruleName) =>
"@typescript-eslint/tslint",
"react",
"jsx-a11y",
],
settings: {
react: {
version: "detect",
}
},
rules: Object.assign(
typescriptEslintRecommended.rules,
typescriptRecommended.rules,
typescriptEslintPrettier.rules,
react.rules,
jsxA11y.rules,
reactPrettier.rules,
{
"@typescript-eslint/adjacent-overload-signatures": "error",
// TODO: (cvle) change `readonly` param to `array-simple` when upgraded typescript.
"@typescript-eslint/array-type": ["error", { "default": "array-simple", "readonly": "generic"}],
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"overrides": {
"constructors": "off",
},
/* eslint-disable @typescript-eslint/no-require-imports */
/**
* 批量删除 eslint-config-prettier 中的规则
*/
import fs from 'fs';
import path from 'path';
import rimraf from 'rimraf';
const prettier = require('eslint-config-prettier');
const prettierReact = require('eslint-config-prettier/react');
const prettierVue = require('eslint-config-prettier/vue');
const prettierTypeScript = require('eslint-config-prettier/@typescript-eslint');
const prettierRules = {
index: prettier.rules,
react: prettierReact.rules,
vue: prettierVue.rules,
typescript: prettierTypeScript.rules
};
const RULE_PREFIX_MAP = {
index: '',
react: 'react/',
vue: 'vue/',
typescript: '@typescript-eslint/'
};
type RulePrefix = keyof typeof RULE_PREFIX_MAP;
const namespaces: RulePrefix[] = ['index', 'react', 'vue', 'typescript'];
namespaces.forEach((namespace) => {
fs.readdirSync(path.resolve(__dirname, '../test', namespace))
/* eslint-disable @typescript-eslint/no-require-imports */
import fs from 'fs';
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
/* eslint-disable @typescript-eslint/no-require-imports */
import fs from 'fs';
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
if (ruleValue.meta.deprecated) {
deprecatedRules.push(fullRuleName);
import fs from 'fs';
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
if (ruleValue.meta.deprecated) {
deprecatedRules.push(fullRuleName);
return;
}
if (prettierRules.includes(fullRuleName)) {
return;
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
if (ruleValue.meta.deprecated) {
deprecatedRules.push(fullRuleName);
return;
}
if (prettierRules.includes(fullRuleName)) {
return;
}
/* eslint-disable @typescript-eslint/no-require-imports */
import fs from 'fs';
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
if (ruleValue.meta.deprecated) {
deprecatedRules.push(fullRuleName);
return;
/* eslint-disable @typescript-eslint/no-require-imports */
import fs from 'fs';
import path from 'path';
import { NAMESPACE_CONFIG, NAMESPACES } from '../config';
/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
...Object.keys(require('eslint-config-prettier').rules),
...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
...Object.keys(require('eslint-config-prettier/babel').rules),
...Object.keys(require('eslint-config-prettier/flowtype').rules),
...Object.keys(require('eslint-config-prettier/react').rules),
...Object.keys(require('eslint-config-prettier/standard').rules),
...Object.keys(require('eslint-config-prettier/unicorn').rules),
...Object.keys(require('eslint-config-prettier/vue').rules)
];
// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
const ruleEntries = pluginName
? Object.entries(require(pluginName).rules)
: Array.from(require('eslint/lib/rules').entries());
ruleEntries.forEach(([ruleName, ruleValue]) => {
const fullRuleName = rulePrefix + ruleName;
if (ruleValue.meta.deprecated) {
deprecatedRules.push(fullRuleName);
return;
}
if (prettierRules.includes(fullRuleName)) {