@longzai-intelligence-oxlint/react-plugin 0.1.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 +17 -0
- package/dist/configs/recommended.d.ts +5 -0
- package/dist/configs/recommended.js +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @longzai-intelligence-oxlint/react-plugin
|
|
2
|
+
|
|
3
|
+
## 意图
|
|
4
|
+
|
|
5
|
+
在静态检查阶段守护 React 项目中的 Hook 命名约定,避免错误的 Hook 命名导致 Hooks 规则误判。
|
|
6
|
+
|
|
7
|
+
## 定位
|
|
8
|
+
|
|
9
|
+
Oxlint 生态的 React 专属规则插件,通过 `eslintCompatPlugin` 包装以同时兼容 Oxlint 与 ESLint 运行时。
|
|
10
|
+
|
|
11
|
+
## 职能
|
|
12
|
+
|
|
13
|
+
提供 `no-incorrect-hook-naming` 规则,校验以 `use` 前缀命名的函数是否符合 Hook 语义约束。
|
|
14
|
+
|
|
15
|
+
## 实现情况
|
|
16
|
+
|
|
17
|
+
当前仅落地 Hook 命名一条规则,规则与插件对象均已导出;其余 React 专属规则尚未纳入,整体处于聚焦单点的成熟形态。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"@longzai-intelligence-oxlint/react-plugin/no-incorrect-hook-naming":`error`};export{e as recommended};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/rules/no-incorrect-hook-naming/no-incorrect-hook-naming.rule.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* no-incorrect-hook-naming 规则定义
|
|
4
|
+
*/
|
|
5
|
+
declare const noIncorrectHookNamingRule: import("@oxlint/plugins").Rule;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/index.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* React 插件
|
|
10
|
+
*
|
|
11
|
+
* 提供 React 相关的 Oxlint 规则,
|
|
12
|
+
* 通过 eslintCompatPlugin 包装以同时支持 Oxlint 和 ESLint 运行时
|
|
13
|
+
*/
|
|
14
|
+
declare const reactPlugin: import("@oxlint/plugins").Plugin;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { reactPlugin as default, reactPlugin, noIncorrectHookNamingRule };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=/\/hooks\//,r=/^use-[a-z][-a-z0-9]*(?:\.hook)?\.tsx?$/,i=/\.hook\.tsx?$/,a=/^use[A-Za-z-]*\.types\.ts$/;function o(e){return`${e.replace(/\.tsx?$/,``).replace(/\.hook$/,``).split(`-`).map((e,t)=>t===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(``)}${e.endsWith(`.tsx`)?`.tsx`:`.ts`}`}const s=e({meta:{type:`problem`,docs:{description:`检测 hooks/ 目录下不规范的 hook 文件命名`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`);if(!n.test(t))return!1},Program(t){let s=e.filename.replace(/\\/g,`/`);if(!n.test(s))return;let c=s.split(`/`).pop()??``;if(r.test(c)){let n=o(c);e.report({node:t,message:`Hook 文件命名违规: ${c} 使用了 kebab-case。应使用 camelCase,如 ${n}`});return}if(i.test(c)){let n=c.replace(/\.hook(\.tsx?)$/,`$1`);e.report({node:t,message:`Hook 文件命名违规: ${c} 使用了 .hook 后缀。应移除 .hook 后缀,如 ${n}`});return}if(a.test(c)){e.report({node:t,message:`Hook 文件命名违规: ${c}。类型文件不应以 use 开头`});return}}}}}),c=t({meta:{name:`@longzai-intelligence-oxlint/react-plugin`},rules:{"no-incorrect-hook-naming":s}});export{c as default,c as reactPlugin,s as noIncorrectHookNamingRule};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-oxlint/react-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./configs/recommended": {
|
|
17
|
+
"types": "./dist/configs/recommended.d.ts",
|
|
18
|
+
"import": "./dist/configs/recommended.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "lzi-builder",
|
|
23
|
+
"build:prod": "NODE_ENV=production lzi-builder",
|
|
24
|
+
"prepublishOnly": "bun run build:prod",
|
|
25
|
+
"dev": "lzi-builder --watch",
|
|
26
|
+
"clean": "rimraf dist",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"test:coverage": "vitest run --coverage",
|
|
30
|
+
"lint": "oxlint && oxfmt --check",
|
|
31
|
+
"lint:fix": "oxlint --fix && oxfmt",
|
|
32
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
33
|
+
"typecheck:app": "tsgo --noEmit -p tsconfig/app.json",
|
|
34
|
+
"typecheck:node": "tsgo --noEmit -p tsconfig/node.json",
|
|
35
|
+
"typecheck:test": "tsgo --noEmit -p tsconfig/test.json"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@longzai-intelligence-oxlint/core": "0.1.0",
|
|
39
|
+
"@oxlint/plugins": "^1.74.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
43
|
+
"typescript": "^6.0.3"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"oxlint": ">=1.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|