Skip to content

Commit 628cab1

Browse files
committed
fix: tidy
1 parent 9ea643d commit 628cab1

2 files changed

Lines changed: 28 additions & 40 deletions

File tree

eslint.config.cjs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ module.exports = [
3030
'n/no-unsupported-features/es-syntax': 'off',
3131
'@typescript-eslint/no-explicit-any': 'off',
3232
'@typescript-eslint/no-require-imports': 'off',
33-
"@typescript-eslint/no-unused-vars": [
34-
"error",
33+
'@typescript-eslint/consistent-type-imports': 'error',
34+
'@typescript-eslint/no-unused-vars': [
35+
'error',
3536
{
36-
"args": "all",
37-
"argsIgnorePattern": "^_",
38-
"caughtErrors": "all",
39-
"caughtErrorsIgnorePattern": "^_",
40-
"destructuredArrayIgnorePattern": "^_",
41-
"varsIgnorePattern": "^_",
42-
"ignoreRestSiblings": true
37+
'args': 'all',
38+
'argsIgnorePattern': '^_',
39+
'caughtErrors': 'all',
40+
'caughtErrorsIgnorePattern': '^_',
41+
'destructuredArrayIgnorePattern': '^_',
42+
'varsIgnorePattern': '^_',
43+
'ignoreRestSiblings': true
4344
}
4445
]
4546
},

src/after-compile.ts

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import type * as ts from 'typescript';
2+
import type ts from 'typescript';
33
import * as webpack from 'webpack';
44

55
import * as constants from './constants';
@@ -127,17 +127,15 @@ function determineModules(
127127
{ filePathKeyMapper, isWebpack5 }: TSInstance
128128
) {
129129
const modules: Map<FilePathKey, webpack.Module[]> = new Map();
130-
const isWebpack5Compilation =
131-
isWebpack5 || !!(compilation as any).compiler?.webpack;
132130

133131
compilation.modules.forEach(module => {
134-
const resource = isWebpack5Compilation
132+
const resource = isWebpack5
135133
? module instanceof webpack.NormalModule
136134
? module.resource
137135
: undefined
138136
: (module as webpack.Module & { resource?: string }).resource;
139137

140-
if (typeof resource === 'string') {
138+
if (resource) {
141139
const modulePath = filePathKeyMapper(resource);
142140
const existingModules = modules.get(modulePath);
143141
if (existingModules !== undefined) {
@@ -268,15 +266,13 @@ function provideErrorsToWebpack(
268266
compilation.compiler.context
269267
);
270268

271-
// if (!moduleHasErrors(module, instance.isWebpack5)) {
272-
formattedErrors.forEach(error => {
273-
if (module.addError) {
274-
module.addError(error);
275-
} else {
276-
module.errors.push(error);
277-
}
278-
});
279-
// }
269+
formattedErrors.forEach(error => {
270+
if (module.addError) {
271+
module.addError(error);
272+
} else {
273+
module.errors.push(error);
274+
}
275+
});
280276

281277
compilation.errors.push(...formattedErrors);
282278
});
@@ -338,15 +334,13 @@ function provideSolutionErrorsToWebpack(
338334
compilation.compiler.context
339335
);
340336

341-
// if (!moduleHasErrors(module, instance.isWebpack5)) {
342-
formattedErrors.forEach(error => {
343-
if (module.addError) {
344-
module.addError(error);
345-
} else {
346-
module.errors.push(error);
347-
}
348-
});
349-
// }
337+
formattedErrors.forEach(error => {
338+
if (module.addError) {
339+
module.addError(error);
340+
} else {
341+
module.errors.push(error);
342+
}
343+
});
350344

351345
compilation.errors.push(...formattedErrors);
352346
});
@@ -556,7 +550,7 @@ function removeModuleTSLoaderError(
556550
});
557551
errors
558552
.filter(
559-
(error: any) => !isTSLoaderModuleError(error, loaderOptions)
553+
(error) => !isTSLoaderModuleError(error, loaderOptions)
560554
)
561555
.forEach((error: webpack.WebpackError) => {
562556
webpackModule.errors.push(error);
@@ -578,10 +572,3 @@ function isTSLoaderModuleError(error: any, loaderOptions: LoaderOptions) {
578572
error?.error?.details === source
579573
);
580574
}
581-
582-
// function moduleHasErrors(module: webpack.Module, isWebpack5: boolean) {
583-
// return isWebpack5
584-
// ? Array.from(module.getErrors!() || []).length > 0
585-
// : (((module as any).errors as webpack.WebpackError[] | undefined) || [])
586-
// .length > 0;
587-
// }

0 commit comments

Comments
 (0)