@longzai-intelligence-oxlint/eslint-config-plugin 0.1.36 → 0.1.37

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=[],r=[];function i(e){if(typeof e!=`object`||!e)return!1;if(`configPackagePath`in e){let t=Object.getOwnPropertyDescriptor(e,`configPackagePath`)?.value;if(t!==void 0&&typeof t!=`string`)return!1}if(`allowedCreateFunctions`in e){let t=Object.getOwnPropertyDescriptor(e,`allowedCreateFunctions`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`forbiddenDefaultExports`in e){let t=Object.getOwnPropertyDescriptor(e,`forbiddenDefaultExports`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}return!0}function a(e){let t=Array.isArray(e)?e[0]:e;return i(t)?{configPackagePath:t.configPackagePath??``,allowedCreateFunctions:t.allowedCreateFunctions??n,forbiddenDefaultExports:t.forbiddenDefaultExports??r}:{configPackagePath:``,allowedCreateFunctions:n,forbiddenDefaultExports:r}}function o(e){return e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null}function s(e,t){let n=!1,r=[],i=[];for(let a of e){if(a.type===`ImportDefaultSpecifier`||a.type===`ImportNamespaceSpecifier`){n=!0;continue}if(a.type===`ImportSpecifier`){let e=a.imported?.type===`Identifier`?a.imported.name:null;if(!e)continue;t.forbiddenDefaultExports.includes(e)?i.push(e):t.allowedCreateFunctions.includes(e)&&r.push(e)}}return{hasDefaultOrNamespace:n,validNames:r,invalidNames:i}}function c(e,t){return e.some(e=>e.type===`ImportSpecifier`&&e.imported?.type===`Identifier`&&e.imported.name!==void 0&&!t.allowedCreateFunctions.includes(e.imported.name)&&!t.forbiddenDefaultExports.includes(e.imported.name))}const l=e({meta:{type:`problem`,docs:{description:`强制执行 eslint.config.ts 文件中的配置导入规范,必须使用 createXxxConfig 函数`},schema:[{type:`object`,properties:{configPackagePath:{type:`string`},allowedCreateFunctions:{type:`array`,items:{type:`string`}},forbiddenDefaultExports:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{ImportDeclaration(t){let n=a(e.options);if(!n.configPackagePath||o(t)!==n.configPackagePath)return;let r=s(t.specifiers,n);if(r.hasDefaultOrNamespace){for(let r of t.specifiers)r.type===`ImportDefaultSpecifier`?e.report({node:r,message:`禁止从 ${n.configPackagePath} 使用默认导入。应使用具名导入 ${n.allowedCreateFunctions.join(`、`)} 等配置创建函数`}):r.type===`ImportNamespaceSpecifier`&&e.report({node:r,message:`禁止从 ${n.configPackagePath} 使用命名空间导入。应使用具名导入 ${n.allowedCreateFunctions.join(`、`)} 等配置创建函数`});return}for(let i of r.invalidNames)e.report({node:t,message:`禁止从配置包导入 "${i}"。应使用 ${n.allowedCreateFunctions.join(`、`)} 等配置创建函数`});r.invalidNames.length===0&&r.validNames.length===0&&(c(t.specifiers,n)||e.report({node:t,message:`必须从 ${n.configPackagePath} 导入至少一个配置创建函数(如 ${n.allowedCreateFunctions.join(`、`)})`}))}}}}),u=t({meta:{name:`@longzai-intelligence-oxlint/eslint-config-plugin`},rules:{"require-eslint-config-import":l}});export{u as default,u as eslintConfigPlugin,l as requireEslintConfigImportRule};
1
+ import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=[],r=[];function i(e){if(typeof e!=`object`||!e)return!1;if(`configPackagePath`in e){let t=Object.getOwnPropertyDescriptor(e,`configPackagePath`)?.value;if(t!==void 0&&typeof t!=`string`)return!1}if(`allowedCreateFunctions`in e){let t=Object.getOwnPropertyDescriptor(e,`allowedCreateFunctions`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}if(`forbiddenDefaultExports`in e){let t=Object.getOwnPropertyDescriptor(e,`forbiddenDefaultExports`)?.value;if(t!==void 0&&!Array.isArray(t))return!1}return!0}function a(e){let t=Array.isArray(e)?e[0]:e;return i(t)?{configPackagePath:t.configPackagePath??``,allowedCreateFunctions:t.allowedCreateFunctions??n,forbiddenDefaultExports:t.forbiddenDefaultExports??r}:{configPackagePath:``,allowedCreateFunctions:n,forbiddenDefaultExports:r}}function o(e){return e.source.type===`Literal`&&typeof e.source.value==`string`?e.source.value:null}function s(e,t){let n=!1,r=[],i=[];for(let a of e)if(a.type===`ImportDefaultSpecifier`||a.type===`ImportNamespaceSpecifier`)n=!0;else if(a.type===`ImportSpecifier`){let e=a.imported?.type===`Identifier`?a.imported.name:null;if(!e)continue;t.forbiddenDefaultExports.includes(e)?i.push(e):t.allowedCreateFunctions.includes(e)&&r.push(e)}return{hasDefaultOrNamespace:n,validNames:r,invalidNames:i}}function c(e,t){return e.some(e=>e.type===`ImportSpecifier`&&e.imported?.type===`Identifier`&&e.imported.name!==void 0&&!t.allowedCreateFunctions.includes(e.imported.name)&&!t.forbiddenDefaultExports.includes(e.imported.name))}const l=e({meta:{type:`problem`,docs:{description:`强制执行 eslint.config.ts 文件中的配置导入规范,必须使用 createXxxConfig 函数`},schema:[{type:`object`,properties:{configPackagePath:{type:`string`},allowedCreateFunctions:{type:`array`,items:{type:`string`}},forbiddenDefaultExports:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{ImportDeclaration(t){let n=a(e.options);if(!n.configPackagePath||o(t)!==n.configPackagePath)return;let r=s(t.specifiers,n);if(r.hasDefaultOrNamespace)for(let r of t.specifiers)r.type===`ImportDefaultSpecifier`?e.report({node:r,message:`禁止从 ${n.configPackagePath} 使用默认导入。应使用具名导入 ${n.allowedCreateFunctions.join(`、`)} 等配置创建函数`}):r.type===`ImportNamespaceSpecifier`&&e.report({node:r,message:`禁止从 ${n.configPackagePath} 使用命名空间导入。应使用具名导入 ${n.allowedCreateFunctions.join(`、`)} 等配置创建函数`});else{for(let i of r.invalidNames)e.report({node:t,message:`禁止从配置包导入 "${i}"。应使用 ${n.allowedCreateFunctions.join(`、`)} 等配置创建函数`});r.invalidNames.length===0&&r.validNames.length===0&&(c(t.specifiers,n)||e.report({node:t,message:`必须从 ${n.configPackagePath} 导入至少一个配置创建函数(如 ${n.allowedCreateFunctions.join(`、`)})`}))}}}}}),u=t({meta:{name:`@longzai-intelligence-oxlint/eslint-config-plugin`},rules:{"require-eslint-config-import":l}});export{u as default,u as eslintConfigPlugin,l as requireEslintConfigImportRule};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-oxlint/eslint-config-plugin",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Longzai Intelligence oxlint ESLint 配置规则插件",
5
5
  "keywords": [
6
6
  "config",
@@ -43,7 +43,7 @@
43
43
  "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
44
44
  },
45
45
  "dependencies": {
46
- "@longzai-intelligence-oxlint/core": "0.1.36",
46
+ "@longzai-intelligence-oxlint/core": "0.1.37",
47
47
  "@oxlint/plugins": "^1.74.0"
48
48
  },
49
49
  "devDependencies": {