First, install Prettier locally:
npm install --save-dev --save-exact prettier
Then, create an empty config file to let editors and other tools know you are using Prettier:
echo {}> .prettierrc.json
Now, format all files with Prettier :
npx prettier --write .
npx prettier --check .
{
"tabWidth": 2,
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
touch .gitignore
node_modules/
{
"extends": ["airbnb", "prettier", "plugin:node/recommended"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"spaced-comment": "off",
"no-console": "warn",
"consistent-return": "off",
"func-names": "off",
"object-shorthand": "off",
"no-process-exit": "off",
"no-param-reassign": "off",
"no-return-await": "off",
"no-underscore-dangle": "off",
"class-methods-use-this": "off",
"prefer-destructuring": ["error", { "object": true, "array": false }],
"no-unused-vars": ["error", { "argsIgnorePattern": "req|res|next|val" }]
}
}