@interlace/eslint-devkit 1.19.3 → 1.19.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interlace/eslint-devkit",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.5",
|
|
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",
|
|
@@ -3,47 +3,20 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
7
|
-
* Whole-word membership tests over an identifier's segments.
|
|
8
|
-
*
|
|
9
|
-
* WHY THIS EXISTS
|
|
10
|
-
*
|
|
11
|
-
* Seven rules independently wrote `haystack.includes(word)` against a
|
|
12
|
-
* vocabulary, and every one of them shipped the same false positives, because
|
|
13
|
-
* English words contain other English words:
|
|
14
|
-
*
|
|
15
|
-
* passengers contains pass → "Password length requirement is too weak"
|
|
16
|
-
* microphoneEnabled contains phone → "PII in console logs"
|
|
17
|
-
* casserole contains role → "Authentication logic in client code"
|
|
18
|
-
* contractAddress contains address → "Sensitive field sent to analytics"
|
|
19
|
-
* promoteOffer contains promote → "Privilege escalation"
|
|
20
|
-
* midnight contains dn → "LDAP injection"
|
|
21
|
-
* sessionStorageKey contains session → "Hardcoded session token"
|
|
22
|
-
*
|
|
23
|
-
* Those are not hypotheticals. Each was produced by running the shipped rule
|
|
24
|
-
* against the snippet above, and `no-client-side-auth-logic` — the `casserole`
|
|
25
|
-
* one — is in `browser-security/recommended` at `error`, so it reached every
|
|
26
|
-
* consumer of the preset.
|
|
27
|
-
*
|
|
28
|
-
* WHAT THIS DOES AND DOES NOT LICENSE
|
|
29
|
-
*
|
|
30
|
-
* Matching a name by whole word is still matching a NAME. CLAUDE.md permits it
|
|
31
|
-
* only where the name NARROWS evidence the rule has already proven — a resolved
|
|
32
|
-
* sink, a resolved taint root, a specific call shape — and never as the whole
|
|
33
|
-
* verdict. Swapping `includes()` for this helper fixes the false-positive half
|
|
34
|
-
* of that defect; it does nothing for the false-negative half, where renaming a
|
|
35
|
-
* genuinely tainted variable silences a real finding. That half needs binding
|
|
36
|
-
* resolution, not better string matching.
|
|
37
|
-
*
|
|
38
|
-
* In other words: this makes a permitted pattern correct. It does not make a
|
|
39
|
-
* forbidden pattern permitted.
|
|
40
|
-
*/
|
|
41
6
|
/**
|
|
42
7
|
* Split an identifier into lower-cased words.
|
|
43
8
|
*
|
|
44
9
|
* Handles camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE, and
|
|
45
10
|
* the acronym boundary (`parseXMLDocument` → `parse`, `xml`, `document`), which
|
|
46
11
|
* a naive `/(?=[A-Z])/` split gets wrong by producing `x`, `m`, `l`.
|
|
12
|
+
*
|
|
13
|
+
* A single left-to-right scan, not a `.replace()` chain: `/([A-Z]+)([A-Z][a-z])/g`
|
|
14
|
+
* against an all-caps string with no trailing lowercase (nothing for the second
|
|
15
|
+
* group to ever match) backtracked the first group one character at a time from
|
|
16
|
+
* every start position — quadratic in the identifier length, and CodeQL flagged
|
|
17
|
+
* it (js/polynomial-redos, alert #1331). `identifierWords` runs on identifiers
|
|
18
|
+
* pulled from whatever source a rule lints, so that length is not this
|
|
19
|
+
* function's to bound. Each character here is inspected exactly once.
|
|
47
20
|
*/
|
|
48
21
|
export declare function identifierWords(name: string): string[];
|
|
49
22
|
/**
|
|
Binary file
|
package/src/resolver/resolver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MissingResolverPeerError=void 0;exports.getResolverPerformanceMetrics=getResolverPerformanceMetrics;exports.resolveModule=resolveModule;exports.clearResolverCache=clearResolverCache;const fs_1=require("../node/fs");const path_1=require("../node/path");const resolver_adapter_1=require("./resolver-adapter");const oxcResolverCache=new Map;let factoryRef;class MissingResolverPeerError extends Error{name="MissingResolverPeerError"}exports.MissingResolverPeerError=MissingResolverPeerError;function loadResolverFactory(){if(factoryRef){return factoryRef}try{factoryRef=require("oxc-resolver").ResolverFactory}catch(cause){throw new MissingResolverPeerError('Import resolution requires the optional peer dependency "oxc-resolver", which is not installed. Install it alongside this plugin:\n\n npm install --save-dev oxc-resolver\n',{cause})}return factoryRef}const tsconfigPathCache=new Map;function findTsconfigPath(fromFile){const startDir=(0,path_1.getDirname)(fromFile);const cached=tsconfigPathCache.get(startDir);if(cached!==void 0){return cached}const result=(0,fs_1.findFileUpward)("tsconfig.json",startDir);let dir=startDir;const root=(0,path_1.resolvePath)("/");while(dir!==root){tsconfigPathCache.set(dir,result);if(result&&(0,path_1.getDirname)(result)===dir)break;const parent=(0,path_1.getDirname)(dir);if(parent===dir)break;dir=parent}return result}function getOxcResolver(options,fromFile){const extensions=options.extensions||[".ts",".tsx",".js",".jsx",".d.ts",".json",".node"];const conditionNames=options.conditionNames||["import","require","node","default","types"];const mainFields=options.mainFields||["module","main"];const tsconfigPath=findTsconfigPath(fromFile);const key=`${extensions.join(",")}|${conditionNames.join(",")}|${mainFields.join(",")}|${tsconfigPath||""}`;const cached=oxcResolverCache.get(key);if(cached){return cached}const resolverOptions={extensions,conditionNames,mainFields,mainFiles:["index"],modules:["node_modules"]};if(tsconfigPath){resolverOptions["tsconfig"]={configFile:tsconfigPath,references:"auto"}}const ResolverFactory=loadResolverFactory();const resolver=new ResolverFactory(resolverOptions);oxcResolverCache.set(key,resolver);return resolver}function isCssImport(importPath){if(/\.(css|scss|sass|less|styl)$/i.test(importPath)){return true}if(importPath.startsWith("./")||importPath.startsWith("../")){return!/\.\w+$/.test(importPath)}return false}function resolveCssImport(importPath,fromFile){const fromDir=(0,path_1.getDirname)(fromFile);if(importPath.startsWith(".")){const resolved=(0,path_1.resolvePath)(fromDir,importPath);if((0,fs_1.fileExistsSync)(resolved)){const stats=(0,fs_1.statSync)(resolved);if(stats&&stats.isFile()){return resolved}}const cssExtensions=[".css",".scss",".sass",".less",".styl"];for(const ext of cssExtensions){const withExt=resolved+ext;if((0,fs_1.fileExistsSync)(withExt)){const stats=(0,fs_1.statSync)(withExt);if(stats&&stats.isFile()){return withExt}}}for(const ext of cssExtensions){const indexFile=(0,path_1.joinPath)(resolved,`index${ext}`);if((0,fs_1.fileExistsSync)(indexFile)){const stats=(0,fs_1.statSync)(indexFile);if(stats&&stats.isFile()){return indexFile}}}}return null}function getResolverPerformanceMetrics(){return[]}function resolveModule(importPath,fromFile,options={}){try{if(importPath.startsWith(".")&&!(options.cssSupport&&isCssImport(importPath))){const context2=(0,path_1.getDirname)(fromFile);const defaultExtensions=[".ts",".tsx",".js",".jsx",".d.ts",".json"];const extensions=options.extensions||defaultExtensions;const resolved=(0,path_1.resolvePath)(context2,importPath);const exactStats=(0,fs_1.statSync)(resolved);if(exactStats&&exactStats.isFile()){return resolved}for(const ext of extensions){if((0,fs_1.fileExistsSync)(resolved+ext)){return resolved+ext}}for(const ext of extensions){const indexFile=(0,path_1.joinPath)(resolved,`index${ext}`);if((0,fs_1.fileExistsSync)(indexFile)){return indexFile}}}if(options.resolverSettings){const externalResult=(0,resolver_adapter_1.resolveWithExternalResolvers)(importPath,fromFile,options.resolverSettings);if(externalResult){return externalResult}}if(options.cssSupport&&isCssImport(importPath)){const cssResult=resolveCssImport(importPath,fromFile);if(cssResult){return cssResult}}const resolver=getOxcResolver(options,fromFile);const context=(0,path_1.getDirname)(fromFile);try{const result=resolver.sync(context,importPath);if(result&&result.path){return result.path}}catch{}return null}catch(error){if(error instanceof MissingResolverPeerError){throw error}return null}}function clearResolverCache(){for(const resolver of oxcResolverCache.values()){resolver.clearCache()}oxcResolverCache.clear();tsconfigPathCache.clear()}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MissingResolverPeerError=void 0;exports.getResolverPerformanceMetrics=getResolverPerformanceMetrics;exports.resolveModule=resolveModule;exports.clearResolverCache=clearResolverCache;const fs_1=require("../node/fs");const path_1=require("../node/path");const resolver_adapter_1=require("./resolver-adapter");const oxcResolverCache=new Map;let factoryRef;class MissingResolverPeerError extends Error{name="MissingResolverPeerError"}exports.MissingResolverPeerError=MissingResolverPeerError;function loadResolverFactory(){if(factoryRef){return factoryRef}try{factoryRef=require("oxc-resolver").ResolverFactory}catch(cause){throw new MissingResolverPeerError('Import resolution requires the optional peer dependency "oxc-resolver", which is not installed. Install it alongside this plugin:\n\n npm install --save-dev oxc-resolver\n',{cause})}return factoryRef}const tsconfigPathCache=new Map;function findTsconfigPath(fromFile){const startDir=(0,path_1.getDirname)(fromFile);const cached=tsconfigPathCache.get(startDir);if(cached!==void 0){return cached}const result=(0,fs_1.findFileUpward)("tsconfig.json",startDir);let dir=startDir;const root=(0,path_1.resolvePath)("/");while(dir!==root){tsconfigPathCache.set(dir,result);if(result&&(0,path_1.getDirname)(result)===dir)break;const parent=(0,path_1.getDirname)(dir);if(parent===dir)break;dir=parent}return result}function getOxcResolver(options,fromFile){const extensions=options.extensions||[".ts",".tsx",".js",".jsx",".d.ts",".json",".node"];const conditionNames=options.conditionNames||["import","require","node","default","types"];const mainFields=options.mainFields||["module","main"];const tsconfigPath=findTsconfigPath(fromFile);const key=`${extensions.join(",")}|${conditionNames.join(",")}|${mainFields.join(",")}|${tsconfigPath||""}`;const cached=oxcResolverCache.get(key);if(cached){return cached}const resolverOptions={extensions,conditionNames,mainFields,mainFiles:["index"],modules:["node_modules"]};if(tsconfigPath){resolverOptions["tsconfig"]={configFile:tsconfigPath,references:"auto"}}const ResolverFactory=loadResolverFactory();const resolver=new ResolverFactory(resolverOptions);oxcResolverCache.set(key,resolver);return resolver}function isCssImport(importPath){if(/\.(css|scss|sass|less|styl)$/i.test(importPath)){return true}if(importPath.startsWith("./")||importPath.startsWith("../")){return!/\.\w+$/.test(importPath)}return false}function resolveCssImport(importPath,fromFile){const fromDir=(0,path_1.getDirname)(fromFile);if(importPath.startsWith(".")){const resolved=(0,path_1.resolvePath)(fromDir,importPath);if((0,fs_1.fileExistsSync)(resolved)){const stats=(0,fs_1.statSync)(resolved);if(stats&&stats.isFile()){return resolved}}const cssExtensions=[".css",".scss",".sass",".less",".styl"];for(const ext of cssExtensions){const withExt=resolved+ext;if((0,fs_1.fileExistsSync)(withExt)){const stats=(0,fs_1.statSync)(withExt);if(stats&&stats.isFile()){return withExt}}}for(const ext of cssExtensions){const indexFile=(0,path_1.joinPath)(resolved,`index${ext}`);if((0,fs_1.fileExistsSync)(indexFile)){const stats=(0,fs_1.statSync)(indexFile);if(stats&&stats.isFile()){return indexFile}}}}return null}function getResolverPerformanceMetrics(){return[]}const NODENEXT_SOURCE_EXTENSIONS={".js":[".ts",".tsx"],".mjs":[".mts"],".cjs":[".cts"]};function resolveModule(importPath,fromFile,options={}){try{if(importPath.startsWith(".")&&!(options.cssSupport&&isCssImport(importPath))){const context2=(0,path_1.getDirname)(fromFile);const defaultExtensions=[".ts",".tsx",".js",".jsx",".d.ts",".json"];const extensions=options.extensions||defaultExtensions;const resolved=(0,path_1.resolvePath)(context2,importPath);const exactStats=(0,fs_1.statSync)(resolved);if(exactStats&&exactStats.isFile()){return resolved}for(const[outputExt,sourceExts]of Object.entries(NODENEXT_SOURCE_EXTENSIONS)){if(!resolved.endsWith(outputExt))continue;const stem=resolved.slice(0,-outputExt.length);for(const ext of sourceExts){if((0,fs_1.fileExistsSync)(stem+ext)){return stem+ext}}}for(const ext of extensions){if((0,fs_1.fileExistsSync)(resolved+ext)){return resolved+ext}}for(const ext of extensions){const indexFile=(0,path_1.joinPath)(resolved,`index${ext}`);if((0,fs_1.fileExistsSync)(indexFile)){return indexFile}}}if(options.resolverSettings){const externalResult=(0,resolver_adapter_1.resolveWithExternalResolvers)(importPath,fromFile,options.resolverSettings);if(externalResult){return externalResult}}if(options.cssSupport&&isCssImport(importPath)){const cssResult=resolveCssImport(importPath,fromFile);if(cssResult){return cssResult}}const resolver=getOxcResolver(options,fromFile);const context=(0,path_1.getDirname)(fromFile);try{const result=resolver.sync(context,importPath);if(result&&result.path){return result.path}}catch{}return null}catch(error){if(error instanceof MissingResolverPeerError){throw error}return null}}function clearResolverCache(){for(const resolver of oxcResolverCache.values()){resolver.clearCache()}oxcResolverCache.clear();tsconfigPathCache.clear()}
|