Skip to content

Commit 5bed1ab

Browse files
fix: do not apply typescript rules when emit disabled (#48)
1 parent 8531dce commit 5bed1ab

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

configs.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ function getJavascriptConfig() {
139139
const minVersion = semver.minVersion(packageJson.engines.node).major;
140140

141141
// https://node.green/
142+
// https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
142143
switch (minVersion) {
143144
case 6: {
144145
const config = { ...configs["javascript/es2016"] };
@@ -229,6 +230,17 @@ function getTypescriptConfig() {
229230
}
230231

231232
const tsconfigJson = getJsonFile("tsconfig.json");
233+
234+
const isNoEmitEnabled =
235+
(tsconfigJson &&
236+
tsconfigJson.compilerOptions &&
237+
tsconfigJson.compilerOptions.noEmit) ||
238+
false;
239+
240+
if (isNoEmitEnabled) {
241+
return {};
242+
}
243+
232244
const isStrict =
233245
(tsconfigJson &&
234246
tsconfigJson.compilerOptions &&

configs/javascript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ function getConfig(esVersion) {
11641164
...javascriptConfig.configs.recommended,
11651165
name: `javascript/es${esVersion}`,
11661166
files: [`**/*.{${allExtensions.map((item) => item.slice(1)).join(",")}}`],
1167+
ignores: ["**/*.d.ts"],
11671168
settings: {
11681169
"import/extensions": allExtensions,
11691170
"import/ignore": [

configs/node.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ const commonRules = {
117117

118118
let nodePlugin;
119119

120+
const ignores = ["**/*.d.ts"];
121+
120122
/**
121123
* @returns {Promise<Record<string, string>>} config
122124
*/
@@ -136,6 +138,7 @@ async function getCommonJSConfig() {
136138
return {
137139
...nodeConfig,
138140
name: "node/commonjs",
141+
ignores,
139142
plugins: {
140143
...nodeConfig.plugins,
141144
import: importPlugin,
@@ -182,6 +185,7 @@ async function getModuleConfig() {
182185
return {
183186
...nodeConfig,
184187
name: "node/module",
188+
ignores,
185189
plugins: {
186190
...nodeConfig.plugins,
187191
import: importPlugin,
@@ -221,6 +225,7 @@ async function getDirtyConfig() {
221225
n: nodePlugin,
222226
import: importPlugin,
223227
},
228+
ignores: [...new Set([...commonjsConfig.ignores, ...moduleConfig.ignores])],
224229
languageOptions: {
225230
sourceType: "module",
226231
parserOptions: {

configs/typescript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ async function getTypescriptRecommendedConfig() {
310310
files: [
311311
`**/*.{${typescriptExtensions.map((item) => item.slice(1)).join(",")}}`,
312312
],
313+
ignores: ["**/*.d.ts"],
313314
languageOptions: {
314315
parser: baseConfig.languageOptions.parser,
315316
},

validation/module.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export function getArrayLength(arr: any[]): number;
2+
export const maxInterval: 12;

0 commit comments

Comments
 (0)