Skip to content

Commit 2b8415a

Browse files
authored
refactor: remove negative reset flags (#1868)
1 parent ae9539d commit 2b8415a

File tree

6 files changed

+29
-91
lines changed

6 files changed

+29
-91
lines changed

packages/webpack-cli/README.md

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,6 @@ yarn add webpack-cli --dev
540540
--no-amd Negates amd
541541
--no-bail Negates bail
542542
--no-cache Negates cache
543-
--no-cache-immutable-paths-reset Negates cache-immutable-paths-reset
544-
--no-dependencies-reset Negates dependencies-reset
545-
--no-entry-reset Negates entry-reset
546543
--no-experiments-asset Negates experiments-asset
547544
--no-experiments-async-web-assembly Negates experiments-async-web-assembly
548545
--no-experiments-import-async Negates experiments-import-async
@@ -551,13 +548,9 @@ yarn add webpack-cli --dev
551548
--no-experiments-output-module Negates experiments-output-module
552549
--no-experiments-sync-web-assembly Negates experiments-sync-web-assembly
553550
--no-experiments-top-level-await Negates experiments-top-level-await
554-
--no-externals-reset Negates externals-reset
555-
--no-infrastructure-logging-debug-reset Negates infrastructure-logging-debug-reset
556551
--no-module-expr-context-critical Negates module-expr-context-critical
557552
--no-module-expr-context-recursive Negates module-expr-context-recursive
558-
--no-module-no-parse-reset Negates module-no-parse-reset
559553
--no-module-rules-side-effects Negates module-rules-side-effects
560-
--no-module-rules-reset Negates module-rules-reset
561554
--no-module-strict-export-presence Negates module-strict-export-presence
562555
--no-module-strict-this-context-on-imports Negates module-strict-this-context-on-imports
563556
--no-module-unknown-context-critical Negates module-unknown-context-critical
@@ -585,61 +578,27 @@ yarn add webpack-cli --dev
585578
--no-optimization-split-chunks-hide-path-info Negates optimization-split-chunks-hide-path-info
586579
--no-optimization-used-exports Negates optimization-used-exports
587580
--no-output-compare-before-emit Negates output-compare-before-emit
588-
--no-output-enabled-library-types-reset Negates output-enabled-library-types-reset
589581
--no-output-iife Negates output-iife
590-
--no-output-library-reset Negates output-library-reset
591-
--no-output-library-root-reset Negates output-library-root-reset
592-
--no-output-library-export-reset Negates output-library-export-reset
593-
--no-output-library-name-reset Negates output-library-name-reset
594-
--no-output-library-name-root-reset Negates output-library-name-root-reset
595582
--no-output-library-umd-named-define Negates output-library-umd-named-define
596583
--no-output-module Negates output-module
597584
--no-output-pathinfo Negates output-pathinfo
598585
--no-output-strict-module-exception-handling Negates output-strict-module-exception-handling
599586
--no-performance Negates performance
600587
--no-profile Negates profile
601588
--no-resolve-alias-only-module Negates resolve-alias-only-module
602-
--no-resolve-alias-reset Negates resolve-alias-reset
603-
--no-resolve-alias-fields-reset Negates resolve-alias-fields-reset
604589
--no-resolve-cache Negates resolve-cache
605590
--no-resolve-cache-with-context Negates resolve-cache-with-context
606-
--no-resolve-condition-names-reset Negates resolve-condition-names-reset
607-
--no-resolve-description-files-reset Negates resolve-description-files-reset
608-
--no-resolve-enforce-extension Negates resolve-enforce-extension
609-
--no-resolve-exports-fields-reset Negates resolve-exports-fields-reset
610-
--no-resolve-extensions-reset Negates resolve-extensions-reset
611-
--no-resolve-fully-specified Negates resolve-fully-specified
612-
--no-resolve-main-fields-reset Negates resolve-main-fields-reset
613-
--no-resolve-main-files-reset Negates resolve-main-files-reset
614-
--no-resolve-modules-reset Negates resolve-modules-reset
615-
--no-resolve-restrictions-reset Negates resolve-restrictions-reset
616-
--no-resolve-roots-reset Negates resolve-roots-reset
617591
--no-resolve-symlinks Negates resolve-symlinks
618592
--no-resolve-unsafe-cache Negates resolve-unsafe-cache
619593
--no-resolve-use-sync-file-system-calls Negates resolve-use-sync-file-system-calls
620594
--no-resolve-loader-alias-only-module Negates resolve-loader-alias-only-module
621-
--no-resolve-loader-alias-reset Negates resolve-loader-alias-reset
622-
--no-resolve-loader-alias-fields-reset Negates resolve-loader-alias-fields-reset
623595
--no-resolve-loader-cache Negates resolve-loader-cache
624596
--no-resolve-loader-cache-with-context Negates resolve-loader-cache-with-context
625-
--no-resolve-loader-condition-names-reset Negates resolve-loader-condition-names-reset
626-
--no-resolve-loader-description-files-reset Negates resolve-loader-description-files-reset
627-
--no-resolve-loader-enforce-extension Negates resolve-loader-enforce-extension
628-
--no-resolve-loader-exports-fields-reset Negates resolve-loader-exports-fields-reset
629-
--no-resolve-loader-extensions-reset Negates resolve-loader-extensions-reset
630-
--no-resolve-loader-fully-specified Negates resolve-loader-fully-specified
631-
--no-resolve-loader-main-fields-reset Negates resolve-loader-main-fields-reset
632-
--no-resolve-loader-main-files-reset Negates resolve-loader-main-files-reset
633-
--no-resolve-loader-modules-reset Negates resolve-loader-modules-reset
634-
--no-resolve-loader-restrictions-reset Negates resolve-loader-restrictions-reset
635-
--no-resolve-loader-roots-reset Negates resolve-loader-roots-reset
636597
--no-resolve-loader-symlinks Negates resolve-loader-symlinks
637598
--no-resolve-loader-unsafe-cache Negates resolve-loader-unsafe-cache
638599
--no-resolve-loader-use-sync-file-system-calls Negates resolve-loader-use-sync-file-system-calls
639600
--no-snapshot-build-dependencies-hash Negates snapshot-build-dependencies-hash
640601
--no-snapshot-build-dependencies-timestamp Negates snapshot-build-dependencies-timestamp
641-
--no-snapshot-immutable-paths-reset Negates snapshot-immutable-paths-reset
642-
--no-snapshot-managed-paths-reset Negates snapshot-managed-paths-reset
643602
--no-snapshot-module-hash Negates snapshot-module-hash
644603
--no-snapshot-module-timestamp Negates snapshot-module-timestamp
645604
--no-snapshot-resolve-hash Negates snapshot-resolve-hash
@@ -665,11 +624,8 @@ yarn add webpack-cli --dev
665624
--no-stats-error-details Negates stats-error-details
666625
--no-stats-error-stack Negates stats-error-stack
667626
--no-stats-errors Negates stats-errors
668-
--no-stats-exclude-assets-reset Negates stats-exclude-assets-reset
669-
--no-stats-exclude-modules-reset Negates stats-exclude-modules-reset
670627
--no-stats-hash Negates stats-hash
671628
--no-stats-ids Negates stats-ids
672-
--no-stats-logging-debug-reset Negates stats-logging-debug-reset
673629
--no-stats-logging-trace Negates stats-logging-trace
674630
--no-stats-module-assets Negates stats-module-assets
675631
--no-stats-module-trace Negates stats-module-trace
@@ -688,8 +644,6 @@ yarn add webpack-cli --dev
688644
--no-stats-used-exports Negates stats-used-exports
689645
--no-stats-version Negates stats-version
690646
--no-stats-warnings Negates stats-warnings
691-
--no-stats-warnings-filter-reset Negates stats-warnings-filter-reset
692-
--no-watch-options-ignored-reset Negates watch-options-ignored-reset
693647
--no-watch-options-stdin Negates watch-options-stdin
694648
```
695649

packages/webpack-cli/lib/utils/cli-flags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ let flagsFromCore =
250250
meta.usage = `--${flag} <value>`;
251251
} else {
252252
meta.type = Boolean;
253-
meta.negative = true;
253+
meta.negative = !flag.endsWith('-reset');
254254
meta.usage = `--${flag}`;
255255
}
256256
return {

test/core-flags/module-flags.test.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,17 @@ describe('module config related flag', () => {
2828
}
2929
});
3030

31-
it(`should config --no-${flag.name} correctly`, () => {
32-
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
33-
expect(stderr).toBeFalsy();
34-
if (flag.name.includes('-reset')) {
35-
const option = propName.split('Reset')[0];
36-
expect(stdout).toContain(`${option}: []`);
37-
} else if (flag.name.includes('rules-')) {
38-
expect(stdout).toContain('sideEffects: false');
39-
} else {
40-
expect(stdout).toContain(`${propName}: false`);
41-
}
42-
});
31+
if (!flag.name.endsWith('-reset')) {
32+
it(`should config --no-${flag.name} correctly`, () => {
33+
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
34+
expect(stderr).toBeFalsy();
35+
if (flag.name.includes('rules-')) {
36+
expect(stdout).toContain('sideEffects: false');
37+
} else {
38+
expect(stdout).toContain(`${propName}: false`);
39+
}
40+
});
41+
}
4342
}
4443

4544
if (flag.type === String) {

test/core-flags/output-flags.test.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,14 @@ describe('output config related flag', () => {
3232
}
3333
});
3434

35-
it(`should config --no-${flag.name} correctly`, () => {
36-
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
35+
if (!flag.name.endsWith('-reset')) {
36+
it(`should config --no-${flag.name} correctly`, () => {
37+
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
3738

38-
if (flag.name.includes('loading-types-reset')) {
39-
expect(stderr).toBeFalsy();
40-
if (flag.name === 'output-enabled-wasm-loading-types-reset') {
41-
expect(stdout).toContain(`enabledWasmLoadingTypes: [ 'fetch' ]`);
42-
} else {
43-
expect(stdout).toContain(`enabledChunkLoadingTypes: [ 'jsonp', 'import-scripts' ]`);
44-
}
45-
} else if (flag.name.includes('-reset')) {
46-
const option = propName.split('Reset')[0];
47-
expect(stderr).toBeFalsy();
48-
expect(stdout).toContain(`${option}: []`);
49-
} else {
5039
expect(stderr).toBeFalsy();
5140
expect(stdout).toContain(`${propName}: false`);
52-
}
53-
});
41+
});
42+
}
5443
}
5544

5645
if (flag.type === Number) {

test/core-flags/stats-flags.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ describe('stats config related flag', () => {
2424
}
2525
});
2626

27-
it(`should config --no-${flag.name} correctly`, () => {
28-
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
27+
if (!flag.name.endsWith('-reset')) {
28+
it(`should config --no-${flag.name} correctly`, () => {
29+
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
2930

30-
expect(stderr).toBeFalsy();
31-
if (flag.name.includes('reset')) {
32-
expect(stdout).toContain(`stats: {}`);
33-
} else {
31+
expect(stderr).toBeFalsy();
3432
expect(stdout).toContain(`stats: { ${propName}: false }`);
35-
}
36-
});
33+
});
34+
}
3735
}
3836

3937
if (flag.type === Number) {

test/core-flags/watch-flags.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ describe('watch config related flag', () => {
2323
}
2424
});
2525

26-
it(`should config --no-${flag.name} correctly`, () => {
27-
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
26+
if (!flag.name.endsWith('-reset')) {
27+
it(`should config --no-${flag.name} correctly`, () => {
28+
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
2829

29-
expect(stderr).toBeFalsy();
30-
if (flag.name.includes('reset')) {
31-
expect(stdout).toContain('watch: false');
32-
} else {
30+
expect(stderr).toBeFalsy();
3331
expect(stdout).toContain(`watchOptions: { ${propName}: false }`);
34-
}
35-
});
32+
});
33+
}
3634
}
3735

3836
if (flag.type === Number) {

0 commit comments

Comments
 (0)