Skip to content

Commit

Permalink
updated lint-staged config
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Aug 29, 2023
1 parent a414257 commit 4ccae79
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const micromatch = require('micromatch');
const prettier = require('prettier');

const prettierSupportedExtensions = prettier
.getSupportInfo()
.languages.map(({ extensions }) => extensions)
.flat();
const addQuotes = (a) => `"${a}"`;

module.exports = (allStagedFiles) => {
module.exports = async (allStagedFiles) => {
const prettierSupportedExtensions = (
await prettier.getSupportInfo()
).languages
.map(({ extensions }) => extensions)
.flat();

const prettierFiles = micromatch(
allStagedFiles,
prettierSupportedExtensions.map((extension) => `**/*${extension}`)
prettierSupportedExtensions.map((extension) => `**/*${extension}`),
);
return prettierFiles.length
? [`prettier --write ${prettierFiles.map(addQuotes).join(' ')}`]
Expand Down

0 comments on commit 4ccae79

Please sign in to comment.