@longzai-intelligence-oxlint/vitest-config-plugin 0.1.17 → 0.1.19

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 CHANGED
@@ -1,17 +1,12 @@
1
1
  # @longzai-intelligence-oxlint/vitest-config-plugin
2
2
 
3
- ## 意图
3
+ Longzai Intelligence Oxlint 的 vitest 配置治理插件,强制 vitest 配置文件使用生态共享配置导入。
4
4
 
5
- 强制 vitest 配置文件使用生态共享配置导入,避免各项目散落自定义 vitest 配置造成测试基线漂移。
5
+ ## 简介
6
6
 
7
- ## 定位
7
+ 治理测试配置散落自定义的问题:项目内 vitest 配置文件是否引用生态统一的共享配置包在静态检查阶段校验,防止各项目散落自定义 vitest 配置造成测试基线漂移。
8
8
 
9
- Oxlint 生态的 vitest 配置治理插件,通过 `eslintCompatPlugin` 包装以同时兼容 Oxlint 与 ESLint 运行时。
9
+ ## 能力
10
10
 
11
- ## 职能
12
-
13
- 提供 `require-vitest-config-import` 规则,校验项目内 vitest 配置文件是否引用生态内统一的共享配置包。
14
-
15
- ## 实现情况
16
-
17
- 当前仅落地配置导入约束一条规则,规则与插件对象均已导出;整体处于聚焦单点的成熟形态,未见其他规则占位。
11
+ - `require-vitest-config-import` — 校验 vitest 配置文件引用生态共享配置
12
+ - 同时兼容 Oxlint 与 ESLint 运行时
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=[],r=[],i=[],a=[];function o(e){if(typeof e!=`object`||!e)return!1;if(`configPackagePaths`in e){let t=Object.getOwnPropertyDescriptor(e,`configPackagePaths`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`allowedExportNames`in e){let t=Object.getOwnPropertyDescriptor(e,`allowedExportNames`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`forbiddenExportNames`in e){let t=Object.getOwnPropertyDescriptor(e,`forbiddenExportNames`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`excludedPaths`in e){let t=Object.getOwnPropertyDescriptor(e,`excludedPaths`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}return!0}function s(e){let t=Array.isArray(e)?e[0]:e;return o(t)?{configPackagePaths:t.configPackagePaths??n,allowedExportNames:t.allowedExportNames??r,forbiddenExportNames:t.forbiddenExportNames??i,excludedPaths:t.excludedPaths??a}:{configPackagePaths:n,allowedExportNames:r,forbiddenExportNames:i,excludedPaths:a}}function c(e){return e.replace(/\\/g,`/`).endsWith(`/vitest.config.ts`)}function l(e,t){return t.some(t=>e.includes(t))}function u(e){if(typeof e!=`object`||!e||!(`type`in e)||!(`callee`in e)||Object.getOwnPropertyDescriptor(e,`type`)?.value!==`CallExpression`)return null;let t=Object.getOwnPropertyDescriptor(e,`callee`)?.value;if(typeof t!=`object`||!t)return null;let n=Object.getOwnPropertyDescriptor(t,`type`)?.value,r=Object.getOwnPropertyDescriptor(t,`name`)?.value;return{type:`CallExpression`,callee:{type:typeof n==`string`?n:``,name:typeof r==`string`?r:void 0}}}function d(e){return typeof e==`object`&&!!e&&`type`in e&&Object.getOwnPropertyDescriptor(e,`type`)?.value===`ObjectExpression`}function f(){return{hasValidImport:!1,hasForbiddenImport:!1,hasExportDefault:!1,forbiddenImportName:``}}function p(e){return e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null}function m(e){return e.imported?.type===`Identifier`?e.imported.name??null:null}function h(e){return`必须使用共享配置函数(${e.allowedExportNames.join(`, `)})从 ${e.configPackagePaths.join(` 或 `)} 导入`}function g(e,t,n){if(!c(t)){e.isActive=!1;return}if(e.resolvedOptions=s(n),l(t,e.resolvedOptions.excludedPaths)){e.isActive=!1;return}e.isActive=!0,e.state.hasValidImport=!1,e.state.hasForbiddenImport=!1,e.state.hasExportDefault=!1,e.state.forbiddenImportName=``}function _(e,t,n){if(!(!e.isActive||!e.resolvedOptions||!t))for(let r of n){if(r.type!==`ImportSpecifier`)continue;let n=m(r);if(n){if(t===`vitest`&&e.resolvedOptions.forbiddenExportNames.includes(n)){e.state.hasForbiddenImport=!0,e.state.forbiddenImportName=n;continue}e.resolvedOptions.configPackagePaths.includes(t)&&e.resolvedOptions.allowedExportNames.includes(n)&&(e.state.hasValidImport=!0)}}}function v(e,t,n){if(!e.isActive||!e.resolvedOptions)return;if(e.state.hasExportDefault=!0,e.state.hasForbiddenImport){n(`禁止从 vitest 包导入 "${e.state.forbiddenImportName}"。应使用共享配置函数(${e.resolvedOptions.allowedExportNames.join(`, `)})从 ${e.resolvedOptions.configPackagePaths.join(` 或 `)} 导入`);return}let r=u(t);if(r){r.callee.type===`Identifier`&&r.callee.name&&!e.resolvedOptions.allowedExportNames.includes(r.callee.name)&&!e.state.hasValidImport&&n(h(e.resolvedOptions));return}d(t)&&(e.state.hasValidImport||n(h(e.resolvedOptions)))}function y(e,t){!e.isActive||!e.resolvedOptions||e.state.hasExportDefault||t(`vitest.config.ts 必须使用共享配置函数(${e.resolvedOptions.allowedExportNames.join(`, `)})从 ${e.resolvedOptions.configPackagePaths.join(` 或 `)} 导入`)}const b=e({meta:{type:`problem`,docs:{description:`强制执行 vitest.config.ts 文件中的配置导入规范,必须使用共享配置函数`},schema:[{type:`object`,properties:{configPackagePaths:{type:`array`,items:{type:`string`}},allowedExportNames:{type:`array`,items:{type:`string`}},forbiddenExportNames:{type:`array`,items:{type:`string`}},excludedPaths:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){let t={resolvedOptions:null,state:f(),isActive:!1};return{Program(n){g(t,e.filename,e.options)},ImportDeclaration(e){_(t,p(e),e.specifiers)},ExportDefaultDeclaration(n){n.type!==`ExportDefaultDeclaration`||!n.declaration||typeof n.declaration!=`object`||v(t,n.declaration,t=>{e.report({node:n,message:t})})},"Program:exit"(n){y(t,t=>{e.report({node:n,message:t})})}}}}),x=t({meta:{name:`@longzai-intelligence-oxlint/vitest-config-plugin`},rules:{"require-vitest-config-import":b}});export{x as default,x as vitestConfigPlugin,b as requireVitestConfigImportRule};
1
+ import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=[],r=[],i=[],a=[];function o(e){if(typeof e!=`object`||!e)return!1;if(`configPackagePaths`in e){let t=Object.getOwnPropertyDescriptor(e,`configPackagePaths`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`allowedExportNames`in e){let t=Object.getOwnPropertyDescriptor(e,`allowedExportNames`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`forbiddenExportNames`in e){let t=Object.getOwnPropertyDescriptor(e,`forbiddenExportNames`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`excludedPaths`in e){let t=Object.getOwnPropertyDescriptor(e,`excludedPaths`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}return!0}function s(e){let t=Array.isArray(e)?e[0]:e;return o(t)?{configPackagePaths:t.configPackagePaths??n,allowedExportNames:t.allowedExportNames??r,forbiddenExportNames:t.forbiddenExportNames??i,excludedPaths:t.excludedPaths??a}:{configPackagePaths:n,allowedExportNames:r,forbiddenExportNames:i,excludedPaths:a}}function c(e){return e.replace(/\\/g,`/`).endsWith(`/vitest.config.ts`)}function l(e,t){return t.some(t=>e.includes(t))}function u(e){if(typeof e!=`object`||!e||!(`type`in e)||!(`callee`in e)||Object.getOwnPropertyDescriptor(e,`type`)?.value!==`CallExpression`)return null;let t=Object.getOwnPropertyDescriptor(e,`callee`)?.value;if(typeof t!=`object`||!t)return null;let n=Object.getOwnPropertyDescriptor(t,`type`)?.value,r=Object.getOwnPropertyDescriptor(t,`name`)?.value;return{type:`CallExpression`,callee:{type:typeof n==`string`?n:``,name:typeof r==`string`?r:void 0}}}function d(e){return typeof e==`object`&&!!e&&`type`in e&&Object.getOwnPropertyDescriptor(e,`type`)?.value===`ObjectExpression`}function f(){return{hasValidImport:!1,hasForbiddenImport:!1,hasExportDefault:!1,forbiddenImportName:``}}function p(e){return e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null}function m(e){return e.imported?.type===`Identifier`?e.imported.name??null:null}function h(e){return`必须使用共享配置函数(${e.allowedExportNames.join(`, `)})从 ${e.configPackagePaths.join(` 或 `)} 导入`}function g(e,t,n){if(!c(t)){e.isActive=!1;return}if(e.resolvedOptions=s(n),l(t,e.resolvedOptions.excludedPaths)){e.isActive=!1;return}e.isActive=!0,e.state.hasValidImport=!1,e.state.hasForbiddenImport=!1,e.state.hasExportDefault=!1,e.state.forbiddenImportName=``}function _(e,t,n){if(e.isActive&&e.resolvedOptions&&t)for(let r of n){if(r.type!==`ImportSpecifier`)continue;let n=m(r);if(n){if(t===`vitest`&&e.resolvedOptions.forbiddenExportNames.includes(n)){e.state.hasForbiddenImport=!0,e.state.forbiddenImportName=n;continue}e.resolvedOptions.configPackagePaths.includes(t)&&e.resolvedOptions.allowedExportNames.includes(n)&&(e.state.hasValidImport=!0)}}}function v(e,t,n){if(!e.isActive||!e.resolvedOptions)return;if(e.state.hasExportDefault=!0,e.state.hasForbiddenImport){n(`禁止从 vitest 包导入 "${e.state.forbiddenImportName}"。应使用共享配置函数(${e.resolvedOptions.allowedExportNames.join(`, `)})从 ${e.resolvedOptions.configPackagePaths.join(` 或 `)} 导入`);return}let r=u(t);if(r){r.callee.type===`Identifier`&&r.callee.name&&!e.resolvedOptions.allowedExportNames.includes(r.callee.name)&&!e.state.hasValidImport&&n(h(e.resolvedOptions));return}d(t)&&(e.state.hasValidImport||n(h(e.resolvedOptions)))}function y(e,t){e.isActive&&e.resolvedOptions&&(e.state.hasExportDefault||t(`vitest.config.ts 必须使用共享配置函数(${e.resolvedOptions.allowedExportNames.join(`, `)})从 ${e.resolvedOptions.configPackagePaths.join(` 或 `)} 导入`))}const b=e({meta:{type:`problem`,docs:{description:`强制执行 vitest.config.ts 文件中的配置导入规范,必须使用共享配置函数`},schema:[{type:`object`,properties:{configPackagePaths:{type:`array`,items:{type:`string`}},allowedExportNames:{type:`array`,items:{type:`string`}},forbiddenExportNames:{type:`array`,items:{type:`string`}},excludedPaths:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){let t={resolvedOptions:null,state:f(),isActive:!1};return{Program(n){g(t,e.filename,e.options)},ImportDeclaration(e){_(t,p(e),e.specifiers)},ExportDefaultDeclaration(n){n.type===`ExportDefaultDeclaration`&&n.declaration&&typeof n.declaration==`object`&&v(t,n.declaration,t=>{e.report({node:n,message:t})})},"Program:exit"(n){y(t,t=>{e.report({node:n,message:t})})}}}}),x=t({meta:{name:`@longzai-intelligence-oxlint/vitest-config-plugin`},rules:{"require-vitest-config-import":b}});export{x as default,x as vitestConfigPlugin,b as requireVitestConfigImportRule};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-oxlint/vitest-config-plugin",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"
@@ -35,7 +35,7 @@
35
35
  "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
36
36
  },
37
37
  "dependencies": {
38
- "@longzai-intelligence-oxlint/core": "0.1.17",
38
+ "@longzai-intelligence-oxlint/core": "0.1.19",
39
39
  "@oxlint/plugins": "^1.74.0"
40
40
  },
41
41
  "devDependencies": {