Skip to content

Commit 0bb03f2

Browse files
ersachin3112alexander-akait
authored andcommitted
chore: fix lint
1 parent 4d3e0ee commit 0bb03f2

14 files changed

+74
-87
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
cache: "npm"
4444

4545
- name: Install dependencies
46-
run: npm install
46+
run: npm ci
4747

4848
- name: Lint
4949
run: npm run lint
@@ -90,7 +90,7 @@ jobs:
9090
cache: "npm"
9191

9292
- name: Install dependencies
93-
run: npm install
93+
run: npm ci
9494

9595
- name: Install webpack ${{ matrix.webpack-version }}
9696
if: matrix.webpack-version != 'latest'

eslint.config.mjs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
import { defineConfig } from "eslint/config";
22
import configs from "eslint-config-webpack/configs.js";
3-
import n from "eslint-plugin-n";
43

54
export default defineConfig([
65
{
76
extends: [configs["recommended-dirty"]],
8-
plugins: {
9-
n,
10-
},
11-
rules: {
12-
// Disable experimental Node.js API warnings for os.availableParallelism
13-
// This API is widely supported and stable in practice
14-
"n/no-unsupported-features/node-builtins": [
15-
"error",
16-
{
17-
ignores: ["os.availableParallelism"],
18-
},
19-
],
20-
// Disable problematic unicorn rules to work around security vulnerabilities
21-
"unicorn/no-unnecessary-array-flat-depth": "off",
22-
"unicorn/no-unnecessary-array-splice-count": "off",
23-
"unicorn/no-useless-fallback-in-spread": "off",
24-
},
257
},
268
]);

src/index.js

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,35 @@ const {
3131

3232
/**
3333
* @typedef {Record<string, unknown>} CssNanoOptions
34-
* @property {string=} configFile - Configuration file path
35-
* @property {string | [string, Record<string, unknown>] | undefined=} preset - CSS nano preset
34+
* @property {string=} configFile Configuration file path
35+
* @property {string | [string, Record<string, unknown>] | undefined=} preset CSS nano preset
3636
*/
3737

3838
/** @typedef {Error & { plugin?: string, text?: string, source?: string } | string} Warning */
3939

4040
/**
4141
* @typedef {object} WarningObject
42-
* @property {string} message - Warning message
43-
* @property {string=} plugin - Plugin name
44-
* @property {string=} text - Warning text
45-
* @property {number=} line - Line number
46-
* @property {number=} column - Column number
42+
* @property {string} message Warning message
43+
* @property {string=} plugin Plugin name
44+
* @property {string=} text Warning text
45+
* @property {number=} line Line number
46+
* @property {number=} column Column number
4747
*/
4848

4949
/**
5050
* @typedef {object} ErrorObject
51-
* @property {string} message - Error message
52-
* @property {number=} line - Line number
53-
* @property {number=} column - Column number
54-
* @property {string=} stack - Error stack trace
51+
* @property {string} message Error message
52+
* @property {number=} line Line number
53+
* @property {number=} column Column number
54+
* @property {string=} stack Error stack trace
5555
*/
5656

5757
/**
5858
* @typedef {object} MinimizedResult
59-
* @property {string} code - Minimized code
60-
* @property {RawSourceMap=} map - Source map
61-
* @property {Array<Error | ErrorObject| string>=} errors - Errors
62-
* @property {Array<Warning | WarningObject | string>=} warnings - Warnings
59+
* @property {string} code Minimized code
60+
* @property {RawSourceMap=} map Source map
61+
* @property {Array<Error | ErrorObject| string>=} errors Errors
62+
* @property {Array<Warning | WarningObject | string>=} warnings Warnings
6363
*/
6464

6565
/**
@@ -91,7 +91,7 @@ const {
9191

9292
/**
9393
* @typedef {object} MinimizeFunctionHelpers
94-
* @property {() => boolean | undefined=} supportsWorkerThreads - Check if worker threads are supported
94+
* @property {() => boolean | undefined=} supportsWorkerThreads Check if worker threads are supported
9595
*/
9696

9797
/**
@@ -102,10 +102,10 @@ const {
102102
/**
103103
* @template T
104104
* @typedef {object} InternalOptions
105-
* @property {string} name - Name
106-
* @property {string} input - Input
107-
* @property {RawSourceMap | undefined} inputSourceMap - Input source map
108-
* @property {{ implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> }} minimizer - Minimizer
105+
* @property {string} name Name
106+
* @property {string} input Input
107+
* @property {RawSourceMap | undefined} inputSourceMap Input source map
108+
* @property {{ implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> }} minimizer Minimizer
109109
*/
110110

111111
/**
@@ -124,11 +124,11 @@ const {
124124

125125
/**
126126
* @typedef {object} BasePluginOptions
127-
* @property {Rule=} test - Test rule
128-
* @property {Rule=} include - Include rule
129-
* @property {Rule=} exclude - Exclude rule
130-
* @property {WarningsFilter=} warningsFilter - Warnings filter
131-
* @property {Parallel=} parallel - Parallel option
127+
* @property {Rule=} test Test rule
128+
* @property {Rule=} include Include rule
129+
* @property {Rule=} exclude Exclude rule
130+
* @property {WarningsFilter=} warningsFilter Warnings filter
131+
* @property {Parallel=} parallel Parallel option
132132
*/
133133

134134
/**
@@ -202,7 +202,7 @@ class CssMinimizerPlugin {
202202
/**
203203
* @private
204204
* @param {unknown} input Input to check
205-
* @returns {boolean} - Whether input is a source map
205+
* @returns {boolean} Whether input is a source map
206206
*/
207207
static isSourceMap(input) {
208208
// All required options for `new SourceMapConsumer(...options)`
@@ -226,7 +226,7 @@ class CssMinimizerPlugin {
226226
* @param {WarningsFilter=} warningsFilter Warnings filter
227227
* @param {TraceMap=} sourceMap Source map
228228
* @param {Compilation["requestShortener"]=} requestShortener Request shortener
229-
* @returns {Error & { hideStack?: boolean, file?: string } | undefined} - Built warning
229+
* @returns {Error & { hideStack?: boolean, file?: string } | undefined} Built warning
230230
*/
231231
static buildWarning(
232232
warning,
@@ -309,7 +309,7 @@ class CssMinimizerPlugin {
309309
* @param {string} file File name
310310
* @param {TraceMap=} sourceMap Source map
311311
* @param {Compilation["requestShortener"]=} requestShortener Request shortener
312-
* @returns {Error} - Built error
312+
* @returns {Error} Built error
313313
*/
314314
static buildError(error, file, sourceMap, requestShortener) {
315315
/**
@@ -384,15 +384,17 @@ class CssMinimizerPlugin {
384384
/**
385385
* @private
386386
* @param {Parallel} parallel Parallel option
387-
* @returns {number} - Available number of cores
387+
* @returns {number} Available number of cores
388388
*/
389389
static getAvailableNumberOfCores(parallel) {
390390
// In some cases cpus() returns undefined
391391
// https://github.com/nodejs/node/issues/19022
392392

393393
const cpus =
394+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
394395
typeof os.availableParallelism === "function"
395-
? { length: os.availableParallelism() }
396+
? // eslint-disable-next-line n/no-unsupported-features/node-builtins
397+
{ length: os.availableParallelism() }
396398
: os.cpus() || { length: 1 };
397399

398400
return parallel === true || typeof parallel === "undefined"
@@ -404,7 +406,7 @@ class CssMinimizerPlugin {
404406
* @private
405407
* @template T
406408
* @param {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} implementation Implementation
407-
* @returns {boolean} - Whether worker threads are supported
409+
* @returns {boolean} Whether worker threads are supported
408410
*/
409411
static isSupportsWorkerThreads(implementation) {
410412
return typeof implementation.supportsWorkerThreads !== "undefined"
@@ -418,7 +420,7 @@ class CssMinimizerPlugin {
418420
* @param {Compilation} compilation Compilation
419421
* @param {Record<string, import("webpack").sources.Source>} assets Assets
420422
* @param {{availableNumberOfCores: number}} optimizeOptions Optimize options
421-
* @returns {Promise<void>} - Promise
423+
* @returns {Promise<void>} Promise
422424
*/
423425
async optimize(compiler, compilation, assets, optimizeOptions) {
424426
const cache = compilation.getCache("CssMinimizerWebpackPlugin");
@@ -709,7 +711,7 @@ class CssMinimizerPlugin {
709711

710712
/**
711713
* @param {Compiler} compiler Compiler
712-
* @returns {void} - Void
714+
* @returns {void} Void
713715
*/
714716
apply(compiler) {
715717
const pluginName = this.constructor.name;

src/minify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* @template T
66
* @param {import("./index.js").InternalOptions<T>} options Options
7-
* @returns {Promise<InternalResult>} - Promise with internal result
7+
* @returns {Promise<InternalResult>} Promise with internal result
88
*/
99
async function minify(options) {
1010
const minifyFns = Array.isArray(options.minimizer.implementation)
@@ -63,7 +63,7 @@ async function minify(options) {
6363

6464
/**
6565
* @param {string} options Options string
66-
* @returns {Promise<InternalResult>} - Promise with internal result
66+
* @returns {Promise<InternalResult>} Promise with internal result
6767
*/
6868
async function transform(options) {
6969
// 'use strict' => this === undefined (Clean Scope)

src/utils.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function throttleAll(limit, tasks) {
7373
* @param {Input} input Input
7474
* @param {RawSourceMap=} sourceMap Source map
7575
* @param {CustomOptions=} minimizerOptions Minimizer options
76-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
76+
* @returns {Promise<MinimizedResult>} Promise with minimized result
7777
*/
7878
async function cssnanoMinify(
7979
input,
@@ -83,7 +83,7 @@ async function cssnanoMinify(
8383
/**
8484
* @template T
8585
* @param {string} module Module to load
86-
* @returns {Promise<T>} - Promise with loaded module
86+
* @returns {Promise<T>} Promise with loaded module
8787
*/
8888
const load = async (module) => {
8989
let exports;
@@ -120,7 +120,10 @@ async function cssnanoMinify(
120120
/** @type {ProcessOptions} */
121121
const postcssOptions = {
122122
from: name,
123-
...(minimizerOptions.processorOptions || {}),
123+
...(minimizerOptions.processorOptions &&
124+
typeof minimizerOptions.processorOptions === "object"
125+
? minimizerOptions.processorOptions
126+
: {}),
124127
};
125128

126129
if (typeof postcssOptions.parser === "string") {
@@ -194,7 +197,7 @@ cssnanoMinify.supportsWorkerThreads = () => true;
194197
* @param {Input} input Input
195198
* @param {RawSourceMap=} sourceMap Source map
196199
* @param {CustomOptions=} minimizerOptions Minimizer options
197-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
200+
* @returns {Promise<MinimizedResult>} Promise with minimized result
198201
*/
199202
async function cssoMinify(input, sourceMap, minimizerOptions) {
200203
const csso = require("csso");
@@ -223,7 +226,7 @@ cssoMinify.supportsWorkerThreads = () => true;
223226
* @param {Input} input Input
224227
* @param {RawSourceMap=} sourceMap Source map
225228
* @param {CustomOptions=} minimizerOptions Minimizer options
226-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
229+
* @returns {Promise<MinimizedResult>} Promise with minimized result
227230
*/
228231
async function cleanCssMinify(input, sourceMap, minimizerOptions) {
229232
const CleanCSS = require("clean-css");
@@ -249,7 +252,7 @@ async function cleanCssMinify(input, sourceMap, minimizerOptions) {
249252
generatedSourceMap.sources = generatedSourceMap.sources.map(
250253
/**
251254
* @param {string | null} item Path item
252-
* @returns {string} - Normalized path
255+
* @returns {string} Normalized path
253256
*/
254257
(item) =>
255258
isWindowsPathSep ? (item || "").replaceAll("\\", "/") : item || "",
@@ -270,12 +273,12 @@ cleanCssMinify.supportsWorkerThreads = () => true;
270273
* @param {Input} input Input
271274
* @param {RawSourceMap=} sourceMap Source map
272275
* @param {CustomOptions=} minimizerOptions Minimizer options
273-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
276+
* @returns {Promise<MinimizedResult>} Promise with minimized result
274277
*/
275278
async function esbuildMinify(input, sourceMap, minimizerOptions) {
276279
/**
277280
* @param {import("esbuild").TransformOptions=} esbuildOptions ESBuild options
278-
* @returns {import("esbuild").TransformOptions} - Built ESBuild options
281+
* @returns {import("esbuild").TransformOptions} Built ESBuild options
279282
*/
280283
const buildEsbuildOptions = (esbuildOptions = {}) =>
281284
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
@@ -358,14 +361,14 @@ esbuildMinify.supportsWorkerThreads = () => false;
358361
* @param {Input} input Input
359362
* @param {RawSourceMap=} sourceMap Source map
360363
* @param {CustomOptions=} minimizerOptions Minimizer options
361-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
364+
* @returns {Promise<MinimizedResult>} Promise with minimized result
362365
*/
363366
async function parcelCssMinify(input, sourceMap, minimizerOptions) {
364367
const [[filename, code]] = Object.entries(input);
365368
// eslint-disable-next-line jsdoc/no-restricted-syntax
366369
/**
367370
* @param {Partial<import("@parcel/css").TransformOptions<any>>=} parcelCssOptions Parcel CSS options
368-
* @returns {import("@parcel/css").TransformOptions<any>} - Built Parcel CSS options
371+
* @returns {import("@parcel/css").TransformOptions<any>} Built Parcel CSS options
369372
*/
370373
const buildParcelCssOptions = (parcelCssOptions = {}) =>
371374
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
@@ -403,14 +406,14 @@ parcelCssMinify.supportsWorkerThreads = () => false;
403406
* @param {Input} input Input
404407
* @param {RawSourceMap=} sourceMap Source map
405408
* @param {CustomOptions=} minimizerOptions Minimizer options
406-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
409+
* @returns {Promise<MinimizedResult>} Promise with minimized result
407410
*/
408411
async function lightningCssMinify(input, sourceMap, minimizerOptions) {
409412
const [[filename, code]] = Object.entries(input);
410413
// eslint-disable-next-line jsdoc/no-restricted-syntax
411414
/**
412415
* @param {Partial<import("lightningcss").TransformOptions<any>>=} lightningCssOptions Lightning CSS options
413-
* @returns {import("lightningcss").TransformOptions<any>} - Built Lightning CSS options
416+
* @returns {import("lightningcss").TransformOptions<any>} Built Lightning CSS options
414417
*/
415418
const buildLightningCssOptions = (lightningCssOptions = {}) =>
416419
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
@@ -448,13 +451,13 @@ lightningCssMinify.supportsWorkerThreads = () => false;
448451
* @param {Input} input Input
449452
* @param {RawSourceMap=} sourceMap Source map
450453
* @param {CustomOptions=} minimizerOptions Minimizer options
451-
* @returns {Promise<MinimizedResult>} - Promise with minimized result
454+
* @returns {Promise<MinimizedResult>} Promise with minimized result
452455
*/
453456
async function swcMinify(input, sourceMap, minimizerOptions) {
454457
const [[filename, code]] = Object.entries(input);
455458
/**
456459
* @param {Partial<import("@swc/css").MinifyOptions>=} swcOptions SWC options
457-
* @returns {import("@swc/css").MinifyOptions} - Built SWC options
460+
* @returns {import("@swc/css").MinifyOptions} Built SWC options
458461
*/
459462
const buildSwcOptions = (swcOptions = {}) =>
460463
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
@@ -500,7 +503,7 @@ swcMinify.supportsWorkerThreads = () => false;
500503
/**
501504
* @template T
502505
* @param {(() => unknown) | undefined} fn Function to memoize
503-
* @returns {() => T} - Memoized function
506+
* @returns {() => T} Memoized function
504507
*/
505508
function memoize(fn) {
506509
let cache = false;

test/helpers/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @param {import("webpack").Compiler} compiler Webpack compiler
3-
* @returns {Promise<import("webpack").Stats>} - Promise with webpack stats
3+
* @returns {Promise<import("webpack").Stats>} Promise with webpack stats
44
*/
55
export default function compile(compiler) {
66
return new Promise((resolve, reject) => {

test/helpers/emitAssetInChildCompilationLoader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PreCopyPlugin {
2121
}
2222

2323
/**
24-
* @returns {string} - Loader result
24+
* @returns {string} Loader result
2525
*/
2626
export default function loader() {
2727
const callback = this.async();

test/helpers/emitAssetLoader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @param {string} content Loader content
3-
* @returns {string} - Processed content
3+
* @returns {string} Processed content
44
*/
55
export default function loader(content) {
66
this.emitFile("style.css", "a { color: red; }");

test/helpers/emitAssetLoader2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @param {string} content Loader content
3-
* @returns {string} - Processed content
3+
* @returns {string} Processed content
44
*/
55
export default function loader(content) {
66
this.emitFile("style-2.css", "a { color: coral; }");

0 commit comments

Comments
 (0)