@interlace/eslint-devkit 1.17.3 → 1.17.4
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,9 +1,9 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-devkit" target="blank"><img src="https://eslint.interlace.tools/logos/interlace.svg" alt="Interlace" height="90" /></a>
|
|
2
|
+
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-devkit" target="blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/interlace-dark.svg"><img src="https://eslint.interlace.tools/logos/interlace-light.svg" alt="Interlace" height="90" /></picture></a>
|
|
3
3
|
|
|
4
|
-
<a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/logos/oxlint.svg" alt="oxlint" height="90" /></a>
|
|
4
|
+
<a href="https://oxc.rs" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/oxlint-dark.svg"><img src="https://eslint.interlace.tools/logos/oxlint-light.svg" alt="oxlint" height="90" /></picture></a>
|
|
5
5
|
|
|
6
|
-
<a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/logos/eslint.svg" alt="ESLint" height="90" /></a>
|
|
6
|
+
<a href="https://eslint.org" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/eslint-dark.svg"><img src="https://eslint.interlace.tools/logos/eslint-light.svg" alt="ESLint" height="90" /></picture></a>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
# @interlace/eslint-devkit
|
|
@@ -553,5 +553,5 @@ See [CHANGELOG.md](./CHANGELOG.md) for a list of changes and version history.
|
|
|
553
553
|
</p>
|
|
554
554
|
|
|
555
555
|
<p align="center">
|
|
556
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-devkit" target="blank"><img src="https://eslint.interlace.tools/
|
|
556
|
+
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-devkit" target="blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/interlace-dark.svg"><img src="https://eslint.interlace.tools/logos/interlace-light.svg" alt="Interlace" height="70" /></picture></a>
|
|
557
557
|
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interlace/eslint-devkit",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"description": "Toolkit for building ESLint plugins in TypeScript — AST helpers, type utilities, rule-creation scaffolding, security benchmarks, and SARIF output.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -7,7 +7,7 @@ import type { TSESLint } from '@typescript-eslint/utils';
|
|
|
7
7
|
/**
|
|
8
8
|
* Documentation URL resolver function type
|
|
9
9
|
*/
|
|
10
|
-
type DocsUrl = (ruleName: string) => string;
|
|
10
|
+
type DocsUrl = (ruleName: string) => string | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Pure function - doesn't mutate either parameter!
|
|
13
13
|
* Uses the default options and overrides with the options provided by the user
|
|
@@ -116,9 +116,18 @@ export declare namespace RuleCreator {
|
|
|
116
116
|
*/
|
|
117
117
|
export declare function createRuleCreator<PluginDocs = unknown>(urlCreator: DocsUrl): <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<RuleWithMetaAndName<Options, MessageIds, PluginDocs>>) => RuleModuleWithName<MessageIds, Options, PluginDocs>;
|
|
118
118
|
/**
|
|
119
|
-
* Default rule creator
|
|
119
|
+
* Default rule creator. Mints NO documentation URL.
|
|
120
120
|
*
|
|
121
|
-
* This
|
|
121
|
+
* This factory cannot know which plugin a rule belongs to, so any URL it builds is a
|
|
122
|
+
* guess. It used to guess `packages/eslint-plugin/docs/rules/<name>.md` — a package
|
|
123
|
+
* that has never existed in this repo — which every plugin then had to scrub on export
|
|
124
|
+
* via {@link withCanonicalDocsUrls}. That worked only for slugs registered in
|
|
125
|
+
* {@link PLUGIN_DOCS_CATEGORY}: a rule authored before its plugin was registered kept
|
|
126
|
+
* the placeholder and shipped a "see docs" link that 404s in every IDE, CI report and
|
|
127
|
+
* SARIF file.
|
|
128
|
+
*
|
|
129
|
+
* Omitting the URL makes that gap silent-but-correct instead of silently wrong, and
|
|
130
|
+
* {@link withCanonicalDocsUrls} warns when a slug is missing so it gets noticed.
|
|
122
131
|
*/
|
|
123
132
|
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<RuleWithMetaAndName<Options, MessageIds, unknown>>) => RuleModuleWithName<MessageIds, Options, unknown>;
|
|
124
133
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.isTestFilePath=isTestFilePath;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;const generated_file_1=require("./generated-file");const minified_file_1=require("./minified-file");function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}const TEST_DIR_SEGMENTS=new Set(["__tests__","__test__","test","tests","spec","specs","e2e","__mocks__","mocks","fixtures","__fixtures__"]);const TEST_BASENAME=/\.(test|spec|fixture|mock|e2e-spec|stories|story)\.[cm]?[jt]sx?$/;const TEST_DIR_SUFFIX=/[-_](tests?|specs?)$/;const TEST_SUPPORT_DIR=/^test(?:[-_]?(?:utils?|helpers?|support|data|doubles?|factories|fixtures?|setup))$|^testing$/i;function isTestFilePath(filename){if(!filename||filename==="<input>"||filename==="<text>")return false;const slash=Math.max(filename.lastIndexOf("/"),filename.lastIndexOf("\\"));if(TEST_BASENAME.test(filename.slice(slash+1)))return true;if(slash<0)return false;return filename.slice(0,slash).split(/[\\/]/).some(segment=>TEST_DIR_SEGMENTS.has(segment)||TEST_DIR_SUFFIX.test(segment)||TEST_SUPPORT_DIR.test(segment))}function createRuleInternal({create,defaultOptions,meta,name,skipTestFiles,skipGeneratedFiles,skipMinifiedFiles}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){if(skipTestFiles&&isTestFilePath(context.filename))return{};if(skipGeneratedFiles&&(0,generated_file_1.isGeneratedFile)(context.sourceCode))return{};if(skipMinifiedFiles&&(0,minified_file_1.isMinifiedFile)(context.sourceCode))return{};return create(context,applyDefault(resolvedDefaultOptions,context.options))},defaultOptions:resolvedDefaultOptions,meta,name}}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.isTestFilePath=isTestFilePath;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;const generated_file_1=require("./generated-file");const minified_file_1=require("./minified-file");function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}const TEST_DIR_SEGMENTS=new Set(["__tests__","__test__","test","tests","spec","specs","e2e","__mocks__","mocks","fixtures","__fixtures__"]);const TEST_BASENAME=/\.(test|spec|fixture|mock|e2e-spec|stories|story)\.[cm]?[jt]sx?$/;const TEST_DIR_SUFFIX=/[-_](tests?|specs?)$/;const TEST_SUPPORT_DIR=/^test(?:[-_]?(?:utils?|helpers?|support|data|doubles?|factories|fixtures?|setup))$|^testing$/i;function isTestFilePath(filename){if(!filename||filename==="<input>"||filename==="<text>")return false;const slash=Math.max(filename.lastIndexOf("/"),filename.lastIndexOf("\\"));if(TEST_BASENAME.test(filename.slice(slash+1)))return true;if(slash<0)return false;return filename.slice(0,slash).split(/[\\/]/).some(segment=>TEST_DIR_SEGMENTS.has(segment)||TEST_DIR_SUFFIX.test(segment)||TEST_SUPPORT_DIR.test(segment))}function createRuleInternal({create,defaultOptions,meta,name,skipTestFiles,skipGeneratedFiles,skipMinifiedFiles}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){if(skipTestFiles&&isTestFilePath(context.filename))return{};if(skipGeneratedFiles&&(0,generated_file_1.isGeneratedFile)(context.sourceCode))return{};if(skipMinifiedFiles&&(0,minified_file_1.isMinifiedFile)(context.sourceCode))return{};return create(context,applyDefault(resolvedDefaultOptions,context.options))},defaultOptions:resolvedDefaultOptions,meta,name}}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(()=>void 0);exports.ESLintUtils={RuleCreator,applyDefault};const PLUGIN_DOCS_CATEGORY={"plugin-anthropic-security":"security","plugin-gemini-security":"security","plugin-mcp-sdk-security":"security","plugin-openai-security":"security","plugin-browser-security":"security","plugin-drizzle-security":"security","plugin-express-security":"security","plugin-jwt-security":"security","plugin-knex-security":"security","plugin-lambda-security":"security","plugin-mongodb-security":"security","plugin-mysql-security":"security","plugin-nestjs-security":"security","plugin-node-security":"security","plugin-postgresql-security":"security","plugin-prisma-security":"security","plugin-secure-coding":"security","plugin-sequelize-security":"security","plugin-sqlite-security":"security","plugin-typeorm-security":"security","plugin-vercel-ai-security":"security","plugin-conventions":"quality","plugin-import-next":"quality","plugin-maintainability":"quality","plugin-modernization":"quality","plugin-modularity":"quality","plugin-operability":"quality","plugin-react-a11y":"quality","plugin-react-features":"quality","plugin-reliability":"quality"};const docsUrlFor=(pluginSlug,ruleName)=>{const category=PLUGIN_DOCS_CATEGORY[pluginSlug];return category?`https://eslint.interlace.tools/docs/${category}/${pluginSlug}/rules/${ruleName}`:null};exports.docsUrlFor=docsUrlFor;function withCanonicalDocsUrls(pluginSlug,rules){if(!PLUGIN_DOCS_CATEGORY[pluginSlug]){console.warn(`[eslint-devkit] withCanonicalDocsUrls('${pluginSlug}'): slug is not registered in PLUGIN_DOCS_CATEGORY, so no rule in this plugin gets a meta.docs.url. Register it in packages/eslint-devkit/src/rule-creation/rule-creator.ts.`)}for(const name of Object.keys(rules)){const descriptor=Object.getOwnPropertyDescriptor(rules,name);const{get}=descriptor;if(get){Object.defineProperty(rules,name,{...descriptor,get(){const rule=get.call(this);stampDocsUrl(pluginSlug,name,rule);return rule}});continue}stampDocsUrl(pluginSlug,name,descriptor.value)}return rules}function stampDocsUrl(pluginSlug,name,rule){const docs=rule?.meta?.docs;if(!docs)return;const url=(0,exports.docsUrlFor)(pluginSlug,name);if(url)docs.url=url}
|