Skip to content

Commit

Permalink
Add --ignore-unknown flag to Prettier
Browse files Browse the repository at this point in the history
During `common-good fix-staged` we fail when we see files like `foo.png`
staged, because Prettier doesn't know how to write to them. Instead, we
should just ignore those files so that we don't fail pre-commit tests.
  • Loading branch information
christianbundy committed Oct 21, 2020
1 parent 0b0d1b6 commit 16bd4b5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/lint-staged-fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const eslintConfig = require.resolve("./eslint.js");
const stylelintConfig = require.resolve("./stylelint.json");

module.exports = {
"*": "prettier --write",
"*": "prettier --ignore-unknown --write",
"*.css": `stylelint --config ${stylelintConfig} --fix --allow-empty-input`,
"*.{js,jsx,md,ts,tsx}": `eslint -c ${eslintConfig} --fix`,
};
2 changes: 1 addition & 1 deletion config/lint-staged-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const stylelintConfig = require.resolve("./stylelint.json");
module.exports = {
"*.{js,jsx,md,ts,tsx}": `eslint -c ${eslintConfig}`,
"*.css": `stylelint --config ${stylelintConfig} --allow-empty-input`,
"*": "prettier --check",
"*": "prettier --ignore-unknown --check",
};
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const stylelintConfig = require.resolve("./config/stylelint.json");
const testCommands = [
`eslint -c ${eslintConfig} **/*.{js,jsx,md,ts,tsx}`,
`stylelint --config ${stylelintConfig} --allow-empty-input **/*.css`,
"prettier --check .",
"prettier --ignore-unknown --check .",
"depcheck",
];

const fixCommands = [
"prettier --write .",
"prettier --ignore-unknown --write .",
`eslint -c ${eslintConfig} --fix **/*.{js,jsx,md,ts,tsx}`,
`stylelint --config ${stylelintConfig} --fix --allow-empty-input **/*.css`,
"depcheck",
Expand Down
Empty file added x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 16bd4b5

Please sign in to comment.