How to use the check function from prettier

Find comprehensive JavaScript prettier.check code examples handpicked from public code repositorys.

29
30
31
32
33
34
35
36
37
38
const input = fs.readFileSync(file, 'utf8');
const withParserOptions = {
  ...options,
  parser: fileInfo.inferredParser,
};
const isPrettier = prettier.check(input, withParserOptions);
if (!isPrettier) {
  console.log(
    `\x1b[31m ${file} is no prettier, please use npm run prettier and git add !\x1b[0m`
  );
fork icon1
star icon2
watch icon0