Skip to content

Commit 5b4f002

Browse files
committed
Don't load eslintrcs even in expectOnly
1 parent a973a99 commit 5b4f002

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

packages/dtslint/src/lint.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,35 @@ function getEslintOptions(
112112
],
113113
};
114114

115+
// Always disable cascading .eslintrc.* discovery. Contributor-authored config files in
116+
// types/<pkg>/ would otherwise be loaded by ESLint 8's legacy eslintrc engine, which
117+
// resolves `extends` and `parser` (including in `overrides[]`) via
118+
// createRequire(configFilePath).resolve(value) and require()s the result. Since dtslint has
119+
// no file-extension allowlist, a contributor could ship a `.cjs` payload alongside
120+
// `.eslintrc.json` and obtain arbitrary code execution in the lint process.
121+
const baseOverrideConfig = {
122+
plugins: ["@definitelytyped", "@typescript-eslint", "jsdoc"],
123+
parser: "@typescript-eslint/parser",
124+
parserOptions: {
125+
project: true,
126+
warnOnUnsupportedTypeScriptVersion: false,
127+
},
128+
...overrideConfig,
129+
};
130+
115131
if (expectOnly) {
116132
return {
117133
useEslintrc: false,
118-
overrideConfig: {
119-
plugins: ["@definitelytyped", "@typescript-eslint", "jsdoc"],
120-
parser: "@typescript-eslint/parser",
121-
parserOptions: {
122-
project: true,
123-
warnOnUnsupportedTypeScriptVersion: false,
124-
},
125-
...overrideConfig,
126-
},
134+
overrideConfig: baseOverrideConfig,
127135
};
128136
}
129137

130138
return {
131-
overrideConfig,
139+
useEslintrc: false,
140+
overrideConfig: {
141+
...baseOverrideConfig,
142+
extends: ["plugin:@definitelytyped/all"],
143+
},
132144
};
133145
}
134146

0 commit comments

Comments
 (0)