UNPKG

@mega-apps/cli

Version:

Mom builder for all mega modules apps. The recommended basic operation dependency package is attached, and users can check and repair defects in actual applications.

135 lines (125 loc) 3.86 kB
/** * Mom 内置的 eslint 配置文件(代码自动生成) * 注意: * 1. 请不要在这里设置或者覆盖规则,这个文件是自动生成的,会被覆盖 * 2. 你可以将自己定义的规则存放到 `.eslintrc.rules.js` 文件中 * */ const def = (enable, currentValue, restValue) => { const defaultValueMap = { Object: {}, Array: [], Function: () => {}, }; let defaultValue; try { defaultValue = restValue === undefined ? defaultValueMap[currentValue.constructor.name] : restValue; } catch (error) {} return [1, true].includes(enable) ? currentValue : defaultValue; }; const extendFileName = ".eslintrc.rules.js"; const getExtendRules = () => { try { const pkg = path.join(__dirname, extendFileName); require.resolve(pkg); // eslint-disable-next-line global-require return require(`{pkg}`); } catch (e) {} return {}; }; module.exports = { root: true, env: { browser: true, node: true, }, extends: [ /* 引入 eslint-config-airbnb-base 规则 */ "airbnb-base", "@nuxtjs", "@nuxtjs/eslint-config-typescript", "prettier", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:prettier/recommended", "plugin:nuxt/recommended", // 去掉 "plugin:playwright/jest-playwright", 而使用 playwright-test 方式进行测试 "plugin:playwright/playwright-test", ], plugins: ["prettier"], // add your custom rules here rules: { // eslint 对eslint 内置规则的定制 ...def(1, { "no-underscore-dangle": [0], "func-names": [0], "promise/param-names": [0], }), ...def(1, { "vue/no-v-model-argument": ["warn"], "vue/no-mutating-props": ["warn"], "vue/no-v-for-template-key-on-child": [0], "vue/no-v-for-template-key": [0], "vue/multi-word-component-names": ["warn"], }), ...def(1, { "import/extensions": [0], "import/no-extraneous-dependencies": [0], "import/no-unresolved": [0], }), // prettier/prettier 对prettier规则的定制 ...def(1, { "prettier/prettier": [ "error", { // 使用 2 个空格缩进 tabWidth: 2, // 不使用缩进符,而使用空格 useTabs: false, // 行尾需要有分号 semi: true, // 不使用单引号 singleQuote: false, // 对象的 key 仅在必要时用引号 quoteProps: "as-needed", // jsx 不使用单引号,而使用双引号 jsxSingleQuote: false, // 末尾不需要逗号 trailingComma: "es5", // 大括号内的首尾需要空格 bracketSpacing: true, // 箭头函数,只有一个参数的时候,也需要括号 arrowParens: "always", // 每个文件格式化的范围是文件的全部内容 rangeStart: 0, rangeEnd: Infinity, // 不需要写文件开头的 @prettier requirePragma: false, // 不需要自动在文件开头插入 @prettier insertPragma: false, // 使用默认的折行标准 proseWrap: "preserve", // 根据显示样式决定 html 要不要折行 htmlWhitespaceSensitivity: "css", // 换行符使用 lf endOfLine: "lf", }, { usePrettierrc: false, }, ], }), // @typescript-eslint ...def(1, { "@typescript-eslint/no-var-requires": [0], "@typescript-eslint/no-empty-function": [0], "@typescript-eslint/no-explicit-any": [0], "@typescript-eslint/no-unused-vars": [0], "@typescript-eslint/explicit-module-boundary-types": [0], }), ...def(1, getExtendRules()), }, };