Skip to content

Commit a67337b

Browse files
authored
Merge pull request #1259 from Agoric/mk/better-format-hint
lint: highlight `yarn format` usage on errors
2 parents 63e6d5b + 790be34 commit a67337b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint-fix": "yarn lint --fix",
1313
"lint": "eslint 'snippets/**/*.js'",
1414
"format": "node scripts/markdown-js-snippets-linter.mjs 'main/**/*.md' --fix && prettier --write '**/*.md' --config .prettierrc.json",
15-
"lint:format": "node scripts/markdown-js-snippets-linter.mjs 'main/**/*.md' && prettier --check '**/*.md' --config .prettierrc.json",
15+
"lint:format": "node scripts/format.mjs",
1616
"build": "exit 0"
1717
},
1818
"packageManager": "[email protected]",

scripts/format.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { exec } from 'child_process';
2+
3+
exec('node scripts/markdown-js-snippets-linter.mjs "main/**/*.md" && prettier --check "**/*.md" --config .prettierrc.json', (err, stdout, stderr) => {
4+
if (err) {
5+
const modifiedStderr = stderr.replace(
6+
'Run Prettier with --write to fix',
7+
'Run `yarn format` to fix'
8+
);
9+
console.warn(modifiedStderr);
10+
process.exit(1);
11+
}
12+
});

scripts/markdown-js-snippets-linter.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const processFiles = async (globPattern, fix = false) => {
206206
if (fix) {
207207
console.log("All matching files have been updated with the necessary changes.");
208208
} else {
209-
console.error("Run with --fix to automatically fix these errors and replace \`\`\`javascript with \`\`\`js.");
209+
console.error("Run `yarn format` to automatically fix these errors");
210210
}
211211
} else {
212212
console.log("No errors found in any of the matching files.");

0 commit comments

Comments
 (0)