@longzai-intelligence/oxlint-plugin-perfectionist 0.0.1
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/dist/configs/recommended.cjs +1 -0
- package/dist/configs/recommended.d.cts +6 -0
- package/dist/configs/recommended.d.mts +6 -0
- package/dist/configs/recommended.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.mjs +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e={"@longzai-intelligence/perfectionist/sort-imports":`error`,"@longzai-intelligence/perfectionist/sort-named-imports":`error`};exports.recommended=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"@longzai-intelligence/perfectionist/sort-imports":`error`,"@longzai-intelligence/perfectionist/sort-named-imports":`error`};export{e as recommended};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@oxlint/plugins`);const t=[/^@\//,/^@main\//,/^@renderer\//,/^@preload\//,/^@shared\//],n=/^@longzai-intelligence\//;function r(e){return e.type===`Program`}function i(e){return e.type===`ImportDeclaration`}function a(e,r){return r?`type`:t.some(t=>t.test(e))?`internal`:n.test(e)?`external`:e.startsWith(`.`)?e===`.`||e===`./`?`index`:e.startsWith(`../`)?`parent`:`sibling`:`external`}const o={type:0,"side-effect":1,external:2,internal:3,parent:4,sibling:5,index:6,unknown:7},s=(0,e.defineRule)({meta:{type:`layout`,docs:{description:`对 import 语句进行排序`}},createOnce(e){return{Program(t){if(!r(t))return;let n=t.body,s=[];for(let e of n)if(i(e)){let t=e.source.value,n=e.importKind===`type`;s.push({node:e,source:t,group:a(t,n),isType:n})}else e.type===`ExpressionStatement`&&e.expression.type===`CallExpression`&&e.expression.callee.type===`Identifier`&&e.expression.callee.name===`import`&&s.push({node:e,source:``,group:`side-effect`,isType:!1});for(let t=1;t<s.length;t++){let n=s[t-1],r=s[t];!n||!r||o[n.group]>o[r.group]&&e.report({node:r.node,message:`导入顺序错误:'${r.source}' 应在 '${n.source}' 之前`})}}}}});function c(e){return e.type===`ImportDeclaration`}function l(e){return e.type===`ImportSpecifier`}const u={"sort-imports":s,"sort-named-imports":(0,e.defineRule)({meta:{type:`layout`,docs:{description:`对具名导入进行排序`}},createOnce(e){return{ImportDeclaration(t){if(!c(t))return;let n=t.specifiers.filter(l);if(n.length<=1)return;let r=n.map(e=>e.imported.type===`Identifier`?e.imported.name:String(e.imported.value)),i=[...r].sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}));for(let n=0;n<r.length;n++)if(r[n]!==i[n]){e.report({node:t,message:`具名导入未按字母顺序排列:'${r[n]}' 应为 '${i[n]}'`});break}}}}})},d=(0,e.eslintCompatPlugin)({meta:{name:`@longzai-intelligence/perfectionist`},rules:u});exports.default=d,exports.perfectionistPlugin=d,exports.perfectionistRules=u;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _$_oxlint_plugins0 from "@oxlint/plugins";
|
|
2
|
+
import { Rule } from "@oxlint/plugins";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare const perfectionistRules: Record<string, Rule>;
|
|
6
|
+
declare const perfectionistPlugin: _$_oxlint_plugins0.Plugin;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { perfectionistPlugin as default, perfectionistPlugin, perfectionistRules };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _$_oxlint_plugins0 from "@oxlint/plugins";
|
|
2
|
+
import { Rule } from "@oxlint/plugins";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare const perfectionistRules: Record<string, Rule>;
|
|
6
|
+
declare const perfectionistPlugin: _$_oxlint_plugins0.Plugin;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { perfectionistPlugin as default, perfectionistPlugin, perfectionistRules };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=[/^@\//,/^@main\//,/^@renderer\//,/^@preload\//,/^@shared\//],r=/^@longzai-intelligence\//;function i(e){return e.type===`Program`}function a(e){return e.type===`ImportDeclaration`}function o(e,t){return t?`type`:n.some(t=>t.test(e))?`internal`:r.test(e)?`external`:e.startsWith(`.`)?e===`.`||e===`./`?`index`:e.startsWith(`../`)?`parent`:`sibling`:`external`}const s={type:0,"side-effect":1,external:2,internal:3,parent:4,sibling:5,index:6,unknown:7},c=e({meta:{type:`layout`,docs:{description:`对 import 语句进行排序`}},createOnce(e){return{Program(t){if(!i(t))return;let n=t.body,r=[];for(let e of n)if(a(e)){let t=e.source.value,n=e.importKind===`type`;r.push({node:e,source:t,group:o(t,n),isType:n})}else e.type===`ExpressionStatement`&&e.expression.type===`CallExpression`&&e.expression.callee.type===`Identifier`&&e.expression.callee.name===`import`&&r.push({node:e,source:``,group:`side-effect`,isType:!1});for(let t=1;t<r.length;t++){let n=r[t-1],i=r[t];!n||!i||s[n.group]>s[i.group]&&e.report({node:i.node,message:`导入顺序错误:'${i.source}' 应在 '${n.source}' 之前`})}}}}});function l(e){return e.type===`ImportDeclaration`}function u(e){return e.type===`ImportSpecifier`}const d={"sort-imports":c,"sort-named-imports":e({meta:{type:`layout`,docs:{description:`对具名导入进行排序`}},createOnce(e){return{ImportDeclaration(t){if(!l(t))return;let n=t.specifiers.filter(u);if(n.length<=1)return;let r=n.map(e=>e.imported.type===`Identifier`?e.imported.name:String(e.imported.value)),i=[...r].sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}));for(let n=0;n<r.length;n++)if(r[n]!==i[n]){e.report({node:t,message:`具名导入未按字母顺序排列:'${r[n]}' 应为 '${i[n]}'`});break}}}}})},f=t({meta:{name:`@longzai-intelligence/perfectionist`},rules:d});export{f as default,f as perfectionistPlugin,d as perfectionistRules};
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence/oxlint-plugin-perfectionist",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Oxlint perfectionist 兼容插件,提供排序规则的 Oxlint 实现",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
|
+
"module": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": {
|
|
16
|
+
"import": "./dist/index.d.mts",
|
|
17
|
+
"require": "./dist/index.d.cts"
|
|
18
|
+
},
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./configs/recommended": {
|
|
23
|
+
"types": {
|
|
24
|
+
"import": "./dist/configs/recommended.d.mts",
|
|
25
|
+
"require": "./dist/configs/recommended.d.cts"
|
|
26
|
+
},
|
|
27
|
+
"import": "./dist/configs/recommended.mjs",
|
|
28
|
+
"require": "./dist/configs/recommended.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsdown",
|
|
33
|
+
"build:prod": "NODE_ENV=production tsdown",
|
|
34
|
+
"prepublishOnly": "bun run build:prod",
|
|
35
|
+
"dev": "tsdown --watch",
|
|
36
|
+
"clean": "rimraf dist",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest",
|
|
39
|
+
"test:coverage": "vitest run --coverage",
|
|
40
|
+
"lint": "bun run lint:oxlint",
|
|
41
|
+
"lint:oxlint": "oxlint",
|
|
42
|
+
"lint:eslint": "eslint .",
|
|
43
|
+
"lint:fix": "bun run oxc:fix",
|
|
44
|
+
"lint:fix:oxlint": "oxlint --fix",
|
|
45
|
+
"lint:fix:eslint": "eslint . --fix",
|
|
46
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node",
|
|
47
|
+
"typecheck:app": "tsc --noEmit -p tsconfig/app.json",
|
|
48
|
+
"typecheck:node": "tsc --noEmit -p tsconfig/node.json",
|
|
49
|
+
"lint:file": "bun run lint:file:oxlint",
|
|
50
|
+
"lint:file:oxlint": "oxlint",
|
|
51
|
+
"lint:file:eslint": "eslint",
|
|
52
|
+
"fmt": "oxfmt",
|
|
53
|
+
"fmt:check": "oxfmt --check",
|
|
54
|
+
"oxc": "bun run lint:oxlint && bun run fmt:check",
|
|
55
|
+
"oxc:fix": "bun run lint:fix:oxlint && bun run fmt"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@longzai-intelligence/oxlint-core": "0.0.1",
|
|
59
|
+
"@oxlint/plugins": "^1.64.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@longzai-intelligence/eslint-preset-library": "0.2.13",
|
|
63
|
+
"@longzai-intelligence/oxlint-config": "0.0.1",
|
|
64
|
+
"@longzai-intelligence/oxlint-plugin-architecture": "0.0.1",
|
|
65
|
+
"@longzai-intelligence/oxlint-plugin-code-style": "0.0.1",
|
|
66
|
+
"@longzai-intelligence/oxlint-plugin-package-json": "0.0.1",
|
|
67
|
+
"@longzai-intelligence/oxlint-plugin-perfectionist": "0.0.1",
|
|
68
|
+
"@longzai-intelligence/oxlint-plugin-schema-type-separation": "0.0.1",
|
|
69
|
+
"@longzai-intelligence/oxlint-plugin-stylistic": "0.0.1",
|
|
70
|
+
"@longzai-intelligence/oxlint-plugin-tsdoc": "0.0.1",
|
|
71
|
+
"@longzai-intelligence/oxlint-plugin-typescript-eslint": "0.0.1",
|
|
72
|
+
"@longzai-intelligence/oxlint-plugin-zod": "0.0.1",
|
|
73
|
+
"@longzai-intelligence/oxlint-testing": "0.0.1",
|
|
74
|
+
"@longzai-intelligence/oxlint-utils": "0.0.1",
|
|
75
|
+
"@longzai-intelligence/tsdown-config": "0.0.1",
|
|
76
|
+
"@longzai-intelligence/typescript-config": "0.0.3",
|
|
77
|
+
"@longzai-intelligence/vitest-config": "0.0.10",
|
|
78
|
+
"@types/node": "^25.7.0",
|
|
79
|
+
"acorn": "^8.16.0",
|
|
80
|
+
"acorn-loose": "^8.5.2",
|
|
81
|
+
"oxlint": "^1.64.0",
|
|
82
|
+
"rimraf": "^6.1.3",
|
|
83
|
+
"tsdown": "^0.21.10",
|
|
84
|
+
"typescript": "^6.0.3",
|
|
85
|
+
"vitest": "^4.1.6"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"oxlint": ">=1.0.0"
|
|
89
|
+
}
|
|
90
|
+
}
|