Skip to content

Commit 9ff9af4

Browse files
authored
add lint rules for console.log and fix postcss-browser-comments (#1482)
1 parent 143aa15 commit 9ff9af4

File tree

55 files changed

+190
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+190
-88
lines changed

.github/bin/detect-executable-files/to-github-annotations.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ if (!fileNames || !fileNames.length) {
3333
}
3434

3535
if (!process.env.GITHUB_ACTIONS) {
36+
// eslint-disable-next-line no-console
3637
console.log('Unexpected executables:');
3738
fileNames.forEach((f) => {
39+
// eslint-disable-next-line no-console
3840
console.log(`chmod a-x ${f}`);
3941
});
4042
process.exit(1);
@@ -51,6 +53,7 @@ fileNames.forEach((f) => {
5153
},
5254
);
5355

56+
// eslint-disable-next-line no-console
5457
console.log(annotation);
5558
});
5659

.github/bin/format-package-json.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ const formatted = {};
251251
Object.assign(formatted, packageJSONInfo);
252252

253253
if (process.env.GITHUB_ACTIONS && JSON.stringify(formatted, null, '\t') !== packageJSONInfoCopy) {
254+
// eslint-disable-next-line no-console
254255
console.error(`::error file=${path.relative(process.env.GITHUB_WORKSPACE, path.resolve('./package.json'))},line=1,col=1::package.json has an incorrect field order. Run "npm run lint" to resolve.`);
255256
process.exit(1);
256257
}

.github/bin/license/check-license.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const allFiles = (await getFiles('./')).filter((file) => {
139139
}
140140

141141
if (logEntries.length > 0) {
142+
// eslint-disable-next-line no-console
142143
console.log(logEntries.join('\n'));
143144
process.exit(1);
144145
}

.github/bin/list-workspaces/list-workspaces.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export async function listWorkspaces() {
7373
});
7474

7575
return result;
76-
} catch(err) {
76+
} catch (err) {
77+
// eslint-disable-next-line no-console
7778
console.error(err);
7879
throw new Error('failed to get the list of workspaces');
7980
}

.github/bin/modified-workspaces/modified-workspaces.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export async function listModifiedWorkspaces() {
6161

6262
for (const internalDependency of internalDependencies) {
6363
if (modifiedFile.startsWith(internalDependency)) {
64+
// eslint-disable-next-line no-console
6465
console.error('modified a private dependency', modifiedFile);
6566
// this file can influence anything
6667
// anything or everything might have changed
@@ -82,6 +83,7 @@ export async function listModifiedWorkspaces() {
8283
}
8384

8485
if (isNonWorkspaceFile) {
86+
// eslint-disable-next-line no-console
8587
console.error('modifiedFile outside of workspaces', modifiedFile);
8688
// files outside of workspaces include "package-lock.json", rollup config, ...
8789
// anything or everything might have changed

.github/bin/new-plugin.mjs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ const pluginName = process.argv.slice(2).join(' ');
66
// Plugin name checks
77
{
88
if (!pluginName) {
9+
// eslint-disable-next-line no-console
910
console.warn('A plugin name must be provided:\n new-plugin <human readable name>\n new-plugin Cascade Layers');
1011
process.exit(1);
1112
}
1213

1314
if (pluginName.startsWith('postcss-')) {
15+
// eslint-disable-next-line no-console
1416
console.warn('Plugin name cannot start with "postcss-", it is added by this scripts.');
1517
process.exit(1);
1618
}
1719

1820
if (pluginName.includes('/')) {
21+
// eslint-disable-next-line no-console
1922
console.warn('Plugin name cannot contain "/"');
2023
process.exit(1);
2124
}
@@ -29,13 +32,15 @@ const exportName = 'postcss' + pluginName.replace(/\s+/g, '');
2932
const basePluginDir = './plugins/postcss-base-plugin';
3033
const pluginDir = './plugins/' + pluginSlug;
3134

35+
// eslint-disable-next-line no-console
3236
console.log(`- Creating new plugin ${pluginName}`);
3337

3438
// Copy base plugin
3539
{
3640
await fs.rm(pluginDir, { recursive: true, force: true });
3741
await fs.cp(basePluginDir, pluginDir, { recursive: true });
3842

43+
// eslint-disable-next-line no-console
3944
console.log('- Copied base plugin to', pluginDir);
4045
}
4146

@@ -44,6 +49,7 @@ console.log(`- Creating new plugin ${pluginName}`);
4449
await fs.rm(path.join(pluginDir, 'dist'), { recursive: true, force: true });
4550
await fs.rm(path.join(pluginDir, 'node_modules'), { recursive: true, force: true });
4651

52+
// eslint-disable-next-line no-console
4753
console.log('- Cleaned up files and directories not required in a new plugin');
4854
}
4955

@@ -65,6 +71,7 @@ console.log(`- Creating new plugin ${pluginName}`);
6571
`,
6672
);
6773

74+
// eslint-disable-next-line no-console
6875
console.log('- Relabeled references to base plugin');
6976
}
7077

@@ -85,21 +92,23 @@ console.log(`- Creating new plugin ${pluginName}`);
8592

8693
await fs.writeFile(path.join(pluginDir, 'package.json'), JSON.stringify(packageInfo, null, '\t'));
8794

95+
// eslint-disable-next-line no-console
8896
console.log('- Updated "package.json"');
8997
}
9098

99+
// eslint-disable-next-line no-console
91100
console.log('\nDone! 🎉');
92101

93102
// Next steps
94103
{
95-
console.log('\nYour next steps:');
96-
console.log('- Run : "npm install" from the root directory');
97-
console.log(`- Run : "cd plugins/${pluginSlug}"`);
98-
console.log('- Run : "npm run docs" to generate documentation');
99-
console.log('- Run : "npm run build" to build your plugin');
100-
console.log('- Run : "npm run test" to test your plugin');
101-
console.log('- Run : "npm run test:rewrite-expects" to update test expects');
102-
console.log('\nChange "blue" to "purple" in "src/index.ts" and see how it affects the test outcome');
104+
console.log('\nYour next steps:'); // eslint-disable-line no-console
105+
console.log('- Run : "npm install" from the root directory'); // eslint-disable-line no-console
106+
console.log(`- Run : "cd plugins/${pluginSlug}"`); // eslint-disable-line no-console
107+
console.log('- Run : "npm run docs" to generate documentation'); // eslint-disable-line no-console
108+
console.log('- Run : "npm run build" to build your plugin'); // eslint-disable-line no-console
109+
console.log('- Run : "npm run test" to test your plugin'); // eslint-disable-line no-console
110+
console.log('- Run : "npm run test:rewrite-expects" to update test expects'); // eslint-disable-line no-console
111+
console.log('\nChange "blue" to "purple" in "src/index.ts" and see how it affects the test outcome'); // eslint-disable-line no-console
103112
}
104113

105114
// Helpers

.github/bin/release-plan/add-to-changelog.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ export function addUpdatedPackagesToChangelog(workspace, changelog, changeLogAdd
33
// Find the heading for the unreleased changes.
44
const unreleasedSectionStart = changelog.indexOf('Unreleased');
55
if (unreleasedSectionStart === -1) {
6+
// eslint-disable-next-line no-console
67
console.log('Unable to update the Changelog for ' + workspace.name);
78
return changelog;
89
}
910

1011
// Find the start of the section content for the unreleased changes.
1112
const unreleasedSectionContent = changelog.indexOf('\n', unreleasedSectionStart) + 1;
1213
if (unreleasedSectionContent === 0) {
14+
// eslint-disable-next-line no-console
1315
console.log('Unable to update the Changelog for ' + workspace.name);
1416
return changelog;
1517
}
@@ -23,13 +25,15 @@ export function addUpdatedPackagesToChangelog(workspace, changelog, changeLogAdd
2325
// Search backward from the next section to find the line for the last unreleased change.
2426
const listEnd = changelog.lastIndexOf('- ', nextSectionStart);
2527
if (listEnd < unreleasedSectionContent) {
28+
// eslint-disable-next-line no-console
2629
console.log('Unable to update the Changelog for ' + workspace.name);
2730
return changelog;
2831
}
2932

3033
// Get the start of the next line after the last change.
3134
const nextLine = changelog.indexOf('\n', listEnd) + 1;
3235
if (nextLine === 0) {
36+
// eslint-disable-next-line no-console
3337
console.log('Unable to update the Changelog for ' + workspace.name);
3438
return changelog;
3539
}

.github/bin/release-plan/discord-announce.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ export async function discordAnnounceDryRun() {
6565

6666
const discordArgument = process.argv.slice(2).find(arg => arg.includes('--discord='));
6767
if (!discordArgument) {
68+
// eslint-disable-next-line no-console
6869
console.log('Discord announce webhook URL: not set');
6970
return;
7071
}
7172

7273
const [, webHookUrl] = discordArgument.split('=');
7374

7475
if (!webHookUrl) {
76+
// eslint-disable-next-line no-console
7577
console.log('Discord announce webhook URL: not set');
7678
return;
7779
}
7880

81+
// eslint-disable-next-line no-console
7982
console.log(`Discord announce webhook URL: ${webHookUrl}`);
8083
}

.github/bin/release-plan/prepare-current-release-plan.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export async function prepareCurrentReleasePlan() {
4949
} else if (changelog.includes('Unreleased (major)')) {
5050
increment = 'major';
5151
} else {
52+
// eslint-disable-next-line no-console
5253
console.warn('Invalid CHANGELOG.md in', workspace.name);
5354
notReleasableNow.set(workspace.name, workspace);
5455
continue WORKSPACES_LOOP;
@@ -61,6 +62,7 @@ export async function prepareCurrentReleasePlan() {
6162
notReleasableNow.set(workspace.name, workspace);
6263
}
6364

65+
// eslint-disable-next-line no-console
6466
console.warn('Current npm user does not have write access for', workspace.name);
6567
continue WORKSPACES_LOOP;
6668
}
@@ -92,23 +94,30 @@ export async function prepareCurrentReleasePlan() {
9294
}
9395

9496
if (needsRelease.size === 0) {
97+
// eslint-disable-next-line no-console
9598
console.log('Nothing to release');
9699
process.exit(0);
97100
}
98101

99102
if (maybeNextPlan.size) {
103+
// eslint-disable-next-line no-console
100104
console.log('Excluded:');
101105
for (const workspace of maybeNextPlan.values()) {
106+
// eslint-disable-next-line no-console
102107
console.log(` - ${workspace.name}`);
103108
}
109+
// eslint-disable-next-line no-console
104110
console.log(''); // empty line
105111
}
106112

107113
if (needsRelease.size) {
114+
// eslint-disable-next-line no-console
108115
console.log('Release plan:');
109116
for (const workspace of needsRelease.values()) {
117+
// eslint-disable-next-line no-console
110118
console.log(` - ${workspace.name} (${workspace.increment})`);
111119
}
120+
// eslint-disable-next-line no-console
112121
console.log(''); // empty line
113122
}
114123

.github/bin/release-plan/prepare-next-release-plan.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export async function prepareNextReleasePlan(needsRelease, notReleasableNow) {
66
// Downstream dependents
77
let didChangeDownstreamPackages = false;
88

9+
// eslint-disable-next-line no-console
910
console.log('\nPreparing next plan');
1011

1112
for (const workspace of notReleasableNow.values()) {

.github/bin/release-plan/release-plan.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if (process.argv.slice(2).includes('--dry-run')) {
2525
}
2626

2727
for (const workspace of needsRelease.values()) {
28+
// eslint-disable-next-line no-console
2829
console.log(`Releasing : ${workspace.name}`);
2930
// Increment the version
3031
workspace.newVersion = await npmVersion(workspace.increment, workspace.path);
@@ -86,21 +87,26 @@ for (const workspace of needsRelease.values()) {
8687

8788
const didChangeDownstreamPackages = await prepareNextReleasePlan(needsRelease, notReleasableNow);
8889

90+
// eslint-disable-next-line no-console
8991
console.log('\nUpdating lock file');
9092
await npmInstall();
9193

9294
if (didChangeDownstreamPackages) {
9395
await commitAfterDependencyUpdates();
9496
}
9597

98+
// eslint-disable-next-line no-console
9699
console.log('\nDone 🎉');
97100

98101
if (didChangeDownstreamPackages || maybeNextPlan.size > 0) {
102+
// eslint-disable-next-line no-console
99103
console.log('\nNotes:'); // empty line
100104
if (didChangeDownstreamPackages) {
105+
// eslint-disable-next-line no-console
101106
console.log(' - updated "package.json" files of downstream packages.');
102107
}
103108
if (maybeNextPlan.size) {
109+
// eslint-disable-next-line no-console
104110
console.log(' - some packages were excluded from this plan. A next plan of releases might be available now.');
105111
}
106112
}

.github/bin/release-plan/run-and-print-debug-on-fail.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ export async function runAndPrintDebugOnFail(runningJob, prelude, helpMessage) {
22
try {
33
await runningJob;
44
} catch (e) {
5+
// eslint-disable-next-line no-console
56
console.error(e);
67

8+
// eslint-disable-next-line no-console
79
console.log(`-----------\n\n${prelude.trim()}\n\n${helpMessage.trim()}`);
810

911
process.exit(1);

cli/csstools-cli/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ async function main(): Promise<void> {
266266
' @csstools/csstools-cli postcss-preset-env',
267267
];
268268

269+
// eslint-disable-next-line no-console
269270
console.warn(allHelp.join('\n'));
270271
}
271272
}

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default [
3939
},
4040

4141
rules: {
42+
'no-console': ['error'],
4243
quotes: ['error', 'single'],
4344
'comma-dangle': ['error', 'always-multiline'],
4445
semi: ['error', 'always'],
@@ -75,6 +76,7 @@ export default [
7576
},
7677

7778
rules: {
79+
'no-console': ['error'],
7880
'no-unused-vars': ['error', { 'caughtErrorsIgnorePattern': '_' }],
7981
'no-constant-condition': 'off',
8082
},
@@ -93,6 +95,7 @@ export default [
9395
},
9496
},
9597
rules: {
98+
'no-console': ['error'],
9699
'no-shadow': 'off',
97100
'@typescript-eslint/no-shadow': 'error',
98101

experimental/css-has-pseudo/dist/browser-global.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/css-has-pseudo/dist/browser.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/css-has-pseudo/dist/browser.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export default function cssHasPseudo() {
2+
// eslint-disable-next-line no-console
23
console.log('"@csstools/css-has-pseudo-experimental" is no longer supported. Please use "css-has-pseudo" instead.');
34
}

packages/base-cli/src/args.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function parseArguments(args: Array<string>, allowedPluginOpts: Array<str
9595
default:
9696
if (arg.indexOf('-') === 0) {
9797
// Stryker disable next-line all
98-
console.warn(`[error] unknown argument : ${arg}\n`);
98+
console.warn(`[error] unknown argument : ${arg}\n`); // eslint-disable-line no-console
9999
// Stryker disable next-line all
100100
helpLogger();
101101
return SignalValue.InvalidArguments;
@@ -123,7 +123,7 @@ export function parseArguments(args: Array<string>, allowedPluginOpts: Array<str
123123

124124
if (parsedArgs.inputs.length > 1 && parsedArgs.output) {
125125
// Stryker disable next-line all
126-
console.warn('[error] omit "--output" when processing multiple inputs\n');
126+
console.warn('[error] omit "--output" when processing multiple inputs\n'); // eslint-disable-line no-console
127127
// Stryker disable next-line all
128128
helpLogger();
129129
return SignalValue.InvalidArguments;
@@ -148,7 +148,7 @@ export function parseArguments(args: Array<string>, allowedPluginOpts: Array<str
148148
parsedPluginOpts = JSON.parse(pluginOpts) as Record<string, unknown>;
149149
} catch {
150150
// Stryker disable next-line all
151-
console.warn('[error] plugin options must be valid JSON\n');
151+
console.warn('[error] plugin options must be valid JSON\n'); // eslint-disable-line no-console
152152
// Stryker disable next-line all
153153
helpLogger();
154154
return SignalValue.InvalidArguments;
@@ -161,7 +161,7 @@ export function parseArguments(args: Array<string>, allowedPluginOpts: Array<str
161161
parsedArgs.pluginOptions[key] = value;
162162
} else {
163163
// Stryker disable next-line all
164-
console.warn(`[error] unknown plugin option: ${key}\n`);
164+
console.warn(`[error] unknown plugin option: ${key}\n`); // eslint-disable-line no-console
165165
// Stryker disable next-line all
166166
helpLogger();
167167
return SignalValue.InvalidArguments;

packages/base-cli/src/help.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function helpTextLogger(command: string, name: string, description: strin
3838
}
3939

4040
return (): void => {
41+
// eslint-disable-next-line no-console
4142
console.warn(allHelp.join('\n'));
4243
};
4344
}

0 commit comments

Comments
 (0)