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);
...reactNative
};
} else {
config.plugins.push('jsx-a11y');
config.rules = {
...config.rules,
...jsxA11y
};
}
}
if (getUsage('prettier')) {
config.rules = {
...config.rules,
...require('eslint-config-prettier').rules,
...require('eslint-config-prettier/babel').rules,
...require('eslint-config-prettier/react').rules,
...require('eslint-config-prettier/unicorn').rules
};
}
module.exports = config;