@houheaven/eslint-config-helper 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -149
- package/exports.js +26 -0
- package/lib/html.js +88 -13
- package/lib/javascript-es5.js +43 -10
- package/lib/javascript-es6.js +51 -11
- package/lib/supports/support-es5.js +25 -0
- package/lib/supports/support-es6.js +35 -0
- package/lib/supports/support-html.js +41 -0
- package/lib/{support/import-support.js → supports/support-import.js} +16 -11
- package/lib/supports/support-typescript.js +34 -0
- package/lib/supports/support-vue2.js +46 -0
- package/lib/supports/support-vue3-ts.js +65 -0
- package/lib/supports/support-vue3.js +46 -0
- package/lib/typescript.js +54 -24
- package/lib/vue2.js +51 -13
- package/lib/vue3.js +95 -14
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/layout-formatting.js +0 -15
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/stylistic.js +24 -0
- package/node_modules/@houheaven/eslint-config-helper-core/utils/utils.js +1 -0
- package/package.json +17 -43
- package/lib/configs/format-prettier.js +0 -478
- package/lib/format-es5.js +0 -23
- package/lib/format-es6.js +0 -25
- package/lib/format-html.js +0 -23
- package/lib/format-import.js +0 -23
- package/lib/format-typescript.js +0 -28
- package/lib/format-vue2.js +0 -23
- package/lib/format-vue3.js +0 -23
- package/lib/import.js +0 -26
- package/lib/support/es5-support.js +0 -29
- package/lib/support/es6-support.js +0 -39
- package/lib/support/html-support.js +0 -38
- package/lib/support/import-bugfix.js +0 -65
- package/lib/support/typescript-support.js +0 -27
- package/lib/support/vue2-support.js +0 -43
- package/lib/support/vue3-support.js +0 -43
- package/lib/support/vue3-ts-support.js +0 -51
- package/lib/utils/utils.js +0 -2
- package/lib/vue3-ts.js +0 -32
package/lib/format-typescript.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/format-typescript
|
|
4
|
-
// ----------------------------------------------------------
|
|
5
|
-
// - @typescript-eslint/eslint-plugin 定制规则(warn)
|
|
6
|
-
// ==========================================================
|
|
7
|
-
|
|
8
|
-
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
overrides: [
|
|
12
|
-
{
|
|
13
|
-
files: ["**/*.ts"],
|
|
14
|
-
// 当 eslint-disable 注释配置未使用时,是否报错
|
|
15
|
-
reportUnusedDisableDirectives: false,
|
|
16
|
-
// 继承配置文件
|
|
17
|
-
extends: [
|
|
18
|
-
// Typescript 支持
|
|
19
|
-
"./support/typescript-support.js",
|
|
20
|
-
],
|
|
21
|
-
// 规则
|
|
22
|
-
rules: {
|
|
23
|
-
// Typescript 规则(warn)
|
|
24
|
-
...utils.getWarnRules("typescript"),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
package/lib/format-vue2.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/format-vue2
|
|
4
|
-
// ----------------------------------------------------------
|
|
5
|
-
// - eslint-plugin-vue 定制规则(warn)
|
|
6
|
-
// ==========================================================
|
|
7
|
-
|
|
8
|
-
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
// 当 eslint-disable 注释配置未使用时,是否报错
|
|
12
|
-
reportUnusedDisableDirectives: false,
|
|
13
|
-
// 继承配置文件
|
|
14
|
-
extends: [
|
|
15
|
-
// Vue2 支持
|
|
16
|
-
"./support/vue2-support.js",
|
|
17
|
-
],
|
|
18
|
-
// 规则
|
|
19
|
-
rules: {
|
|
20
|
-
// Vue2 规则(warn)
|
|
21
|
-
...utils.getWarnRules("vue2"),
|
|
22
|
-
},
|
|
23
|
-
};
|
package/lib/format-vue3.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/format-vue3
|
|
4
|
-
// ----------------------------------------------------------
|
|
5
|
-
// - eslint-plugin-vue 定制规则(warn)
|
|
6
|
-
// ==========================================================
|
|
7
|
-
|
|
8
|
-
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
// 当 eslint-disable 注释配置未使用时,是否报错
|
|
12
|
-
reportUnusedDisableDirectives: false,
|
|
13
|
-
// 继承配置文件
|
|
14
|
-
extends: [
|
|
15
|
-
// Vue3 支持
|
|
16
|
-
"./support/vue3-support.js",
|
|
17
|
-
],
|
|
18
|
-
// 规则
|
|
19
|
-
rules: {
|
|
20
|
-
// Vue3 规则(warn)
|
|
21
|
-
...utils.getWarnRules("vue3"),
|
|
22
|
-
},
|
|
23
|
-
};
|
package/lib/import.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/import
|
|
4
|
-
// ----------------------------------------------------------
|
|
5
|
-
// - eslint-plugin-import 定制规则
|
|
6
|
-
// ==========================================================
|
|
7
|
-
|
|
8
|
-
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
-
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
10
|
-
|
|
11
|
-
const utils = require("@houheaven/eslint-config-helper-core");
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
// 当 eslint-disable 注释配置未使用时,是否报错
|
|
15
|
-
reportUnusedDisableDirectives: true,
|
|
16
|
-
// 继承配置文件
|
|
17
|
-
extends: [
|
|
18
|
-
// eslint-plugin-import 支持
|
|
19
|
-
"./support/import-support.js",
|
|
20
|
-
],
|
|
21
|
-
// 规则
|
|
22
|
-
rules: {
|
|
23
|
-
// eslint-plugin-import 规则
|
|
24
|
-
...utils.rules.import,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// Eslint ES5 支持
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: [
|
|
10
|
-
// js 文件
|
|
11
|
-
"**/*.js",
|
|
12
|
-
// Nodejs CommonJS 模块文件
|
|
13
|
-
"**/*.cjs",
|
|
14
|
-
// Nodejs ESM 模块文件
|
|
15
|
-
"**/*.mjs",
|
|
16
|
-
],
|
|
17
|
-
// 定义环境变量
|
|
18
|
-
env: {
|
|
19
|
-
browser: true, // 浏览器环境,启用浏览器环境的全局变量(window、document、navigator、alert 等)
|
|
20
|
-
jquery: true, // jQuery 环境,启用 jQuery 环境的全局变量和作用域规则($、jQuery 等)
|
|
21
|
-
},
|
|
22
|
-
// 解析器配置
|
|
23
|
-
parserOptions: {
|
|
24
|
-
sourceType: "script", // 指定代码的来源类型,"script"(默认)表示 ESLint 会在全局作用域的脚本上下文中解析代码
|
|
25
|
-
ecmaVersion: 5, // 指定 ECMAScript 版本,5 表示 ECMAScript 5
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// Eslint ES6+ 支持
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: [
|
|
10
|
-
// js 文件
|
|
11
|
-
"**/*.js",
|
|
12
|
-
// Nodejs CommonJS 模块文件
|
|
13
|
-
"**/*.cjs",
|
|
14
|
-
// Nodejs ESM 模块文件
|
|
15
|
-
"**/*.mjs",
|
|
16
|
-
],
|
|
17
|
-
// 定义环境变量
|
|
18
|
-
env: {
|
|
19
|
-
browser: true, // 浏览器环境,启用浏览器环境的全局变量(window、document、navigator、alert 等)
|
|
20
|
-
node: true, // Node.js 环境,启用 Node.js 环境的全局变量和作用域规则(__dirname、__filename、process、global 等)
|
|
21
|
-
commonjs: true, // Node.js 环境,启用 CommonJS 的全局变量和作用域规则(require()、module、exports 等)
|
|
22
|
-
amd: false, // AMD 环境,启用 AMD 环境的全局变量和作用域规则(define()、require() 等)
|
|
23
|
-
mocha: false, // Mocha 环境,启用 Mocha 环境的全局变量和作用域规则(describe()、it()、before()、after() 等)
|
|
24
|
-
jasmine: false, // Jasmine 环境,启用 Jasmine 环境的全局变量和作用域规则(describe()、it()、beforeEach()、afterEach() 等)
|
|
25
|
-
es6: true, // 启用 ECMAScript 6 全局变量和作用域规则(let、const、class、import、export 等)
|
|
26
|
-
},
|
|
27
|
-
// 解析器配置
|
|
28
|
-
parserOptions: {
|
|
29
|
-
sourceType: "module", // 指定代码的来源类型,"module" 表示 ESLint 会在 ECMAScript 模块的上下文中解析代码(即支持 import 和 export 语法)
|
|
30
|
-
ecmaVersion: "latest", // 指定 ECMAScript 版本,"latest" 表示使用最新的 ECMAScript 版本
|
|
31
|
-
ecmaFeatures: {
|
|
32
|
-
generators: false,
|
|
33
|
-
objectLiteralDuplicateProperties: false,
|
|
34
|
-
jsx: true,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// html 支持
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: ["**/*.html", "**/*.htm", "**/*.php"],
|
|
10
|
-
parser: "@html-eslint/parser",
|
|
11
|
-
plugins: [
|
|
12
|
-
// 检查和修复 html 文件中的 html 代码
|
|
13
|
-
"@html-eslint/eslint-plugin",
|
|
14
|
-
// 检查和修复 html 文件中的 JS 代码,即 <script> 中的代码
|
|
15
|
-
// 仅仅提供技术支持,不包含任何规则,具体规则由 eslint.js 提供
|
|
16
|
-
"eslint-plugin-html",
|
|
17
|
-
],
|
|
18
|
-
// eslint-plugin-html 配置
|
|
19
|
-
// 注意:为了使 eslint-plugin-html 插件正常工作,parser 必须是 "@html-eslint/parser",不能是 require.resolve("@html-eslint/parser")
|
|
20
|
-
settings: {
|
|
21
|
-
"html/html-extensions": [".html", ".htm", ".php"],
|
|
22
|
-
"html/javascript-tag-names": ["script"],
|
|
23
|
-
// "html/javascript-mime-types": "/^(application|text)\\/(x-)?(javascript|babel|ecmascript-6|html)$/",
|
|
24
|
-
"html/javascript-mime-types": ["text/javascript", "module"],
|
|
25
|
-
"html/ignore-tags-without-type": false,
|
|
26
|
-
"html/report-bad-indent": "warn",
|
|
27
|
-
"html/indent": "+2",
|
|
28
|
-
},
|
|
29
|
-
// 规则
|
|
30
|
-
rules: {
|
|
31
|
-
// 此处不可删除,解决 html 中 <script> 换行问题
|
|
32
|
-
"eol-last": "off",
|
|
33
|
-
// 解决 HTML 注释(<!-- -->)引起 eslint 报错的问题
|
|
34
|
-
"spaced-comment": "off",
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ===============================================================================
|
|
3
|
-
// eslint-plugin-import 插件的解析器("import/resolver")
|
|
4
|
-
// - 解决 Vue 中设置的别名(比如 @)无法被 import/no-unresolved 规则解析的问题
|
|
5
|
-
// - 解决 ts 文件无法被 import/extensions 规则解析的问题
|
|
6
|
-
// -------------------------------------------------------------------------------
|
|
7
|
-
// 依赖:eslint-import-resolver-node
|
|
8
|
-
// 作用:这是最基础、最标准的解析器。它遵循 Node.js 原生的模块解析机制
|
|
9
|
-
// - 查找 node_modules 中的依赖
|
|
10
|
-
// - 自动补全文件后缀(如 .js、.ts、.node)
|
|
11
|
-
// - 识别 index.js 作为目录入口
|
|
12
|
-
// -------------------------------------------------------------------------------
|
|
13
|
-
// 依赖:eslint-import-resolver-webpack
|
|
14
|
-
// 作用:让 ESLint 能够理解 Webpack 的配置
|
|
15
|
-
// - Webpack 允许配置 resolve.alias(别名,如 @ 指向 src )
|
|
16
|
-
// - Webpack 允许配置 resolve.modules(自定义模块目录)
|
|
17
|
-
// - Webpack 允许配置省略特定的后缀(如 .vue , .jsx )
|
|
18
|
-
// - 如果没有这个解析器,ESLint 会报错说找不到模块( import/no-unresolved ),即使 Webpack 编译能通过。
|
|
19
|
-
// 场景:主要用于 Vue 2 (Vue CLI) 或 React (Create React App) 等基于 Webpack 构建的项目。
|
|
20
|
-
// 在当前场景中,它被用来读取 @vue/cli-service 的 Webpack 配置。
|
|
21
|
-
// -------------------------------------------------------------------------------
|
|
22
|
-
// 依赖:eslint-import-resolver-alias
|
|
23
|
-
// 作用:一个轻量级的解析器,专门用来处理路径别名(Alias),而不依赖庞大的 Webpack 配置。
|
|
24
|
-
// - 简单直接地告诉 ESLint:“当看到 @ 时,去 src 目录下找”。
|
|
25
|
-
// - 它不需要读取复杂的 webpack.config.js ,配置更简单、速度通常更快。
|
|
26
|
-
// 场景 :
|
|
27
|
-
// - Vite 项目 :Vite 不使用 Webpack,所以无法使用 Webpack 解析器。通常配合此包来解决 Vite 中的别名问题。
|
|
28
|
-
// - 非 Webpack 项目 :任何使用了别名但没有 Webpack 的环境。
|
|
29
|
-
// - 在你的项目中,它主要用于 Vue 3 + Vite 的场景。
|
|
30
|
-
// ===============================================================================
|
|
31
|
-
|
|
32
|
-
const path = require("path");
|
|
33
|
-
|
|
34
|
-
const importResolver = {
|
|
35
|
-
// eslint-import-resolver-node 配置项
|
|
36
|
-
// 说明:
|
|
37
|
-
// 使用包的绝对路径作为键名来注册解析器,这是一种防御性写法。
|
|
38
|
-
// 在 Monorepo 或使用了 pnpm 等包管理器的项目中,依赖结构可能比较复杂,
|
|
39
|
-
// 直接写字符串 "node" 有时可能导致 ESLint 找不到对应的解析器包,
|
|
40
|
-
// 使用 require.resolve 可以确保准确找到该包。
|
|
41
|
-
[require.resolve("eslint-import-resolver-node")]: {
|
|
42
|
-
// 文件解析,Node 默认只会解析 js
|
|
43
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts", ".vue"],
|
|
44
|
-
},
|
|
45
|
-
// eslint-import-resolver-alias 配置项(字符串简写)
|
|
46
|
-
// 别名解析
|
|
47
|
-
alias: {
|
|
48
|
-
map: [
|
|
49
|
-
["@", path.resolve(process.cwd(), "src")],
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// 针对 Vue CLI 项目
|
|
55
|
-
try {
|
|
56
|
-
const vueCliConfig = require.resolve("@vue/cli-service/webpack.config.js");
|
|
57
|
-
importResolver[require.resolve("eslint-import-resolver-webpack")] = {
|
|
58
|
-
config: vueCliConfig,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
catch(e) {
|
|
62
|
-
// ignore
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = importResolver;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// Typescript 支持
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: ["**/*.ts"],
|
|
10
|
-
plugins: [
|
|
11
|
-
"@typescript-eslint/eslint-plugin",
|
|
12
|
-
"@stylistic/eslint-plugin",
|
|
13
|
-
],
|
|
14
|
-
parser: require.resolve("@typescript-eslint/parser"),
|
|
15
|
-
parserOptions: {
|
|
16
|
-
sourceType: "module",
|
|
17
|
-
// 零配置方案
|
|
18
|
-
// - 自动适配项目中的 tsconfig.json 配置文件
|
|
19
|
-
// - 不需要指定具体路径,让 ESLint 自动查找
|
|
20
|
-
// 方案一:优先使用用户项目的 tsconfig.json
|
|
21
|
-
// project: true,
|
|
22
|
-
// 方案二:projectService 作为降级方案
|
|
23
|
-
projectService: true,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// vue2 支持
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: ["**/*.vue"],
|
|
10
|
-
plugins: ["eslint-plugin-vue"],
|
|
11
|
-
parser: require.resolve("vue-eslint-parser"),
|
|
12
|
-
parserOptions: {
|
|
13
|
-
sourceType: "module", // 指定代码的来源类型,"module" 表示 ESLint 会在 ECMAScript 模块的上下文中解析代码(即支持 import 和 export 语法)
|
|
14
|
-
ecmaVersion: "latest", // 指定 ECMAScript 版本,"latest" 表示使用最新的 ECMAScript 版本
|
|
15
|
-
ecmaFeatures: {
|
|
16
|
-
jsx: true, // 启用 JSX 全局变量和作用域规则
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
env: {
|
|
20
|
-
browser: true, // 浏览器环境,启用浏览器环境的全局变量(window、document、navigator、alert 等)
|
|
21
|
-
node: true, // Node.js 环境,启用 Node.js 环境的全局变量和作用域规则(__dirname、__filename、process、global 等)
|
|
22
|
-
commonjs: true, // Node.js 环境,启用 CommonJS 的全局变量和作用域规则(require()、module、exports 等)
|
|
23
|
-
es6: true, // 启用 ECMAScript 6 全局变量和作用域规则(let、const、class、import、export 等)
|
|
24
|
-
},
|
|
25
|
-
rules: {
|
|
26
|
-
"indent": "off",
|
|
27
|
-
"max-len": "off",
|
|
28
|
-
"no-irregular-whitespace": "off",
|
|
29
|
-
// 禁止在 Vue 指定的版本上使用不支持的语法
|
|
30
|
-
// https://eslint.vuejs.org/rules/no-unsupported-features.html
|
|
31
|
-
"vue/no-unsupported-features": ["error", {
|
|
32
|
-
"version": "^2.6.0",
|
|
33
|
-
"ignores": [],
|
|
34
|
-
}],
|
|
35
|
-
// 禁止在 props 中使用保留关键字
|
|
36
|
-
// https://eslint.vuejs.org/rules/no-reserved-props.html
|
|
37
|
-
"vue/no-reserved-props": ["error", {
|
|
38
|
-
"vueVersion": 2,
|
|
39
|
-
}],
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// vue3 支持
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: ["**/*.vue"],
|
|
10
|
-
plugins: ["eslint-plugin-vue"],
|
|
11
|
-
parser: require.resolve("vue-eslint-parser"),
|
|
12
|
-
parserOptions: {
|
|
13
|
-
sourceType: "module", // 指定代码的来源类型,"module" 表示 ESLint 会在 ECMAScript 模块的上下文中解析代码(即支持 import 和 export 语法)
|
|
14
|
-
ecmaVersion: "latest", // 指定 ECMAScript 版本,"latest" 表示使用最新的 ECMAScript 版本
|
|
15
|
-
ecmaFeatures: {
|
|
16
|
-
jsx: true, // 启用 JSX 全局变量和作用域规则
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
env: {
|
|
20
|
-
browser: true, // 浏览器环境,启用浏览器环境的全局变量(window、document、navigator、alert 等)
|
|
21
|
-
node: true, // Node.js 环境,启用 Node.js 环境的全局变量和作用域规则(__dirname、__filename、process、global 等)
|
|
22
|
-
commonjs: true, // Node.js 环境,启用 CommonJS 的全局变量和作用域规则(require()、module、exports 等)
|
|
23
|
-
es6: true, // 启用 ECMAScript 6 全局变量和作用域规则(let、const、class、import、export 等)
|
|
24
|
-
},
|
|
25
|
-
rules: {
|
|
26
|
-
"indent": "off",
|
|
27
|
-
"max-len": "off",
|
|
28
|
-
"no-irregular-whitespace": "off",
|
|
29
|
-
// 禁止在 Vue 指定的版本上使用不支持的语法
|
|
30
|
-
// https://eslint.vuejs.org/rules/no-unsupported-features.html
|
|
31
|
-
"vue/no-unsupported-features": ["error", {
|
|
32
|
-
"version": "^3.4.0",
|
|
33
|
-
"ignores": [],
|
|
34
|
-
}],
|
|
35
|
-
// 禁止在 props 中使用保留关键字
|
|
36
|
-
// https://eslint.vuejs.org/rules/no-reserved-props.html
|
|
37
|
-
"vue/no-reserved-props": ["error", {
|
|
38
|
-
"vueVersion": 3,
|
|
39
|
-
}],
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// vue3 支持(TypeScript)
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
files: ["**/*.vue"],
|
|
10
|
-
plugins: ["eslint-plugin-vue"],
|
|
11
|
-
parser: require.resolve("vue-eslint-parser"),
|
|
12
|
-
parserOptions: {
|
|
13
|
-
sourceType: "module", // 指定代码的来源类型,"module" 表示 ESLint 会在 ECMAScript 模块的上下文中解析代码(即支持 import 和 export 语法)
|
|
14
|
-
ecmaVersion: "latest", // 指定 ECMAScript 版本,"latest" 表示使用最新的 ECMAScript 版本
|
|
15
|
-
ecmaFeatures: {
|
|
16
|
-
jsx: true, // 启用 JSX 全局变量和作用域规则
|
|
17
|
-
},
|
|
18
|
-
// Vue 添加对 TypeScript 的支持
|
|
19
|
-
parser: require.resolve("@typescript-eslint/parser"),
|
|
20
|
-
extraFileExtensions: [".vue"],
|
|
21
|
-
// project: true, // 使用 projectService 会报错
|
|
22
|
-
project: [
|
|
23
|
-
"**/tsconfig.json",
|
|
24
|
-
"**/tsconfig.**.json",
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
env: {
|
|
28
|
-
browser: true, // 浏览器环境,启用浏览器环境的全局变量(window、document、navigator、alert 等)
|
|
29
|
-
node: true, // Node.js 环境,启用 Node.js 环境的全局变量和作用域规则(__dirname、__filename、process、global 等)
|
|
30
|
-
commonjs: true, // Node.js 环境,启用 CommonJS 的全局变量和作用域规则(require()、module、exports 等)
|
|
31
|
-
es6: true, // 启用 ECMAScript 6 全局变量和作用域规则(let、const、class、import、export 等)
|
|
32
|
-
},
|
|
33
|
-
rules: {
|
|
34
|
-
"indent": "off",
|
|
35
|
-
"max-len": "off",
|
|
36
|
-
"no-irregular-whitespace": "off",
|
|
37
|
-
// 禁止在 Vue 指定的版本上使用不支持的语法
|
|
38
|
-
// https://eslint.vuejs.org/rules/no-unsupported-features.html
|
|
39
|
-
"vue/no-unsupported-features": ["error", {
|
|
40
|
-
"version": "^3.4.0",
|
|
41
|
-
"ignores": [],
|
|
42
|
-
}],
|
|
43
|
-
// 禁止在 props 中使用保留关键字
|
|
44
|
-
// https://eslint.vuejs.org/rules/no-reserved-props.html
|
|
45
|
-
"vue/no-reserved-props": ["error", {
|
|
46
|
-
"vueVersion": 3,
|
|
47
|
-
}],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
};
|
package/lib/utils/utils.js
DELETED
package/lib/vue3-ts.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/vue3-ts
|
|
4
|
-
// ----------------------------------------------------------
|
|
5
|
-
// - eslint-plugin-vue 定制规则
|
|
6
|
-
// ==========================================================
|
|
7
|
-
|
|
8
|
-
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
-
const utils = require("@houheaven/eslint-config-helper-core");
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
overrides: [
|
|
13
|
-
{
|
|
14
|
-
files: ["**/*.vue"],
|
|
15
|
-
// 当 eslint-disable 注释配置未使用时,是否报错
|
|
16
|
-
reportUnusedDisableDirectives: true,
|
|
17
|
-
// 继承配置文件
|
|
18
|
-
extends: [
|
|
19
|
-
// Vue3 支持
|
|
20
|
-
"./support/vue3-ts-support.js",
|
|
21
|
-
],
|
|
22
|
-
// 规则
|
|
23
|
-
rules: {
|
|
24
|
-
// Vue3 规则
|
|
25
|
-
...utils.rules.vue,
|
|
26
|
-
...utils.rules.vue3,
|
|
27
|
-
// @typescript-eslint/eslint-plugin 规则
|
|
28
|
-
...utils.rules.typescript,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|