diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..e17beb07 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,16 @@ +name: Prettier check + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '18.x' + - run: npm ci + - run: npm run format:check diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..93d0c5df --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +node_modules +.cache +public/ +static/admin/*.bundle.* +.DS_Store +yarn-error.log +.vscode +.netlify diff --git a/package.json b/package.json index 01a31cca..e81fc12a 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,8 @@ "build": "npm run clean && gatsby build", "develop": "npm run clean && gatsby develop", "serve": "gatsby serve", - "format": "prettier --trailing-comma es5 --no-semi --single-quote --write --tab-width 4 \"{gatsby-*.js,src/**/*.js}\"", - "test": "echo \"Error: no test specified\" && exit 1", + "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,mdx,yml,yaml}\"", + "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md,mdx,yml,yaml}\"", "dev": "npx concurrently \"npx netlify-cms-proxy-server\" \"npm start -- --progress\"" }, "devDependencies": { diff --git a/prettierrc.json b/prettierrc.json new file mode 100644 index 00000000..c87a53fe --- /dev/null +++ b/prettierrc.json @@ -0,0 +1,7 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "tabWidth": 4, + "endOfLine": "lf" +}