@lsby/eslint-plugin 0.0.2
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/.prettierignore +51 -0
- package/.prettierrc +9 -0
- package/README.md +39 -0
- package/index.js +5 -0
- package/lib/rules/no-broken-link.js +39 -0
- package/package.json +21 -0
package/.prettierignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# 忽略 node_modules 目录
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# 忽略所有日志文件
|
|
5
|
+
*.log
|
|
6
|
+
|
|
7
|
+
# 忽略构建输出目录
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
|
|
11
|
+
# 忽略环境变量文件
|
|
12
|
+
.env
|
|
13
|
+
.env.local
|
|
14
|
+
.env.*.local
|
|
15
|
+
|
|
16
|
+
# 忽略锁文件
|
|
17
|
+
pnpm-lock.yaml
|
|
18
|
+
yarn.lock
|
|
19
|
+
package-lock.json
|
|
20
|
+
|
|
21
|
+
# 忽略 IDE 配置文件
|
|
22
|
+
.vscode/
|
|
23
|
+
.idea/
|
|
24
|
+
|
|
25
|
+
# 忽略临时文件
|
|
26
|
+
*.tmp
|
|
27
|
+
*.temp
|
|
28
|
+
|
|
29
|
+
# 忽略特定文件类型
|
|
30
|
+
*.min.js
|
|
31
|
+
*.min.css
|
|
32
|
+
|
|
33
|
+
# 忽略特定文件
|
|
34
|
+
pnpm-lock.yaml
|
|
35
|
+
|
|
36
|
+
# 忽略图片和其他媒体文件
|
|
37
|
+
*.png
|
|
38
|
+
*.jpg
|
|
39
|
+
*.jpeg
|
|
40
|
+
*.gif
|
|
41
|
+
*.svg
|
|
42
|
+
|
|
43
|
+
# 忽略压缩文件
|
|
44
|
+
*.zip
|
|
45
|
+
*.tar.gz
|
|
46
|
+
*.rar
|
|
47
|
+
|
|
48
|
+
# 忽略文档
|
|
49
|
+
*.pdf
|
|
50
|
+
*.docx
|
|
51
|
+
*.xlsx
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"printWidth": 120,
|
|
3
|
+
"trailingComma": "all",
|
|
4
|
+
"semi": false,
|
|
5
|
+
"endOfLine": "auto",
|
|
6
|
+
"singleQuote": true,
|
|
7
|
+
"plugins": ["prettier-plugin-packagejson", "@ianvs/prettier-plugin-sort-imports"],
|
|
8
|
+
"importOrder": ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^@([^/]+?)/(.*)$", "^[./]"]
|
|
9
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# eslint-plugin
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
一些自己写的eslint插件
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
1. **安装包**
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm i @lsby/eslint-plugin
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. **安装 ESLint**
|
|
16
|
+
|
|
17
|
+
确保你的项目中已安装 ESLint 和 TypeScript ESLint 解析器。如果尚未安装,可以使用以下命令进行安装:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. **配置 ESLint**
|
|
24
|
+
|
|
25
|
+
在你的 ESLint 配置文件中引入并启用规则:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
module.exports = {
|
|
29
|
+
parser: '@typescript-eslint/parser',
|
|
30
|
+
plugins: ['@typescript-eslint'],
|
|
31
|
+
extends: [
|
|
32
|
+
'eslint:recommended',
|
|
33
|
+
'plugin:@typescript-eslint/recommended'
|
|
34
|
+
],
|
|
35
|
+
rules: {
|
|
36
|
+
'@lsby/no-broken-link': 'error',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: "problem", // 规则类型,可以是 "problem", "suggestion", 或 "layout"
|
|
4
|
+
docs: {
|
|
5
|
+
description: "Check for broken {@link} references in comments",
|
|
6
|
+
category: "Possible Errors",
|
|
7
|
+
recommended: false,
|
|
8
|
+
},
|
|
9
|
+
schema: [], // 规则的选项配置
|
|
10
|
+
},
|
|
11
|
+
create: function(context) {
|
|
12
|
+
return {
|
|
13
|
+
Program(node) {
|
|
14
|
+
const sourceCode = context.getSourceCode();
|
|
15
|
+
const comments = sourceCode.getAllComments();
|
|
16
|
+
|
|
17
|
+
comments.forEach(comment => {
|
|
18
|
+
const matches = comment.value.match(/\{@link\s+([^\s}]+)\s*\}/g);
|
|
19
|
+
|
|
20
|
+
if (matches) {
|
|
21
|
+
matches.forEach(link => {
|
|
22
|
+
const identifier = link.match(/\{@link\s+([^\s}]+)\s*\}/)[1];
|
|
23
|
+
|
|
24
|
+
const variables = context.getScope().variables;
|
|
25
|
+
const isDefined = variables.some(variable => variable.name === identifier);
|
|
26
|
+
|
|
27
|
+
if (!isDefined) {
|
|
28
|
+
context.report({
|
|
29
|
+
node: comment,
|
|
30
|
+
message: `The identifier "${identifier}" in {@link} is not defined.`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lsby/eslint-plugin",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"pub:public": "bumpp && npm publish --access public",
|
|
7
|
+
"test": "mocha test/**/*.test.js"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
|
|
11
|
+
"bumpp": "^9.5.1",
|
|
12
|
+
"chai": "^5.1.1",
|
|
13
|
+
"mocha": "^10.7.3",
|
|
14
|
+
"prettier": "^3.3.3",
|
|
15
|
+
"prettier-plugin-packagejson": "^2.5.1"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"eslint": "^8.56.0"
|
|
19
|
+
},
|
|
20
|
+
"packageManager": "pnpm@9.5.0"
|
|
21
|
+
}
|