diff --git a/.husky/pre-commit b/.husky/pre-commit index 3867a0fe..5ec09714 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,2 @@ npm run lint +npm run format:check diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..1ab0cbdb --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +# Add files here to ignore them from prettier formatting + +**/package-lock.json + +**/*.js +**/*.?js +**/*.ts +**/*.?ts +**/*.md + +test-project/cypress/ diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..ac0f0e9a --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": false, + "trailingComma": "all", + "arrowParens": "always", + "singleQuote": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea1f0ff5..5b262b1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,7 @@ To add a new rule: * Run `eslint-doc-generator` to generate automated documentation sections (see [Document generation](#document-generation) below) * Review documentation changes * Run `npm run lint` +* Run `npm run format` * Run `npm test` to run [Vitest](https://vitest.dev/) * Make sure all tests are passing * Add the rule to [flat.js](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/lib/flat.js) diff --git a/circle.yml b/circle.yml index 0f3f4351..6ffc3ce3 100644 --- a/circle.yml +++ b/circle.yml @@ -48,8 +48,11 @@ jobs: name: Show ESLint version command: npx eslint --version - run: - name: Lint code + name: Lint code with ESLint command: npm run lint + - run: + name: Lint code with Prettier + command: npm run format:check test-v9: executor: docker-executor diff --git a/package-lock.json b/package-lock.json index db54163d..c116966e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "eslint-plugin-eslint-plugin": "^6.4.0", "eslint-plugin-mocha": "^11.1.0", "husky": "^9.1.7", + "prettier": "^3.5.3", "semantic-release": "24.2.5", "vitest": "^3.1.4" }, @@ -7395,6 +7396,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-ms": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.2.0.tgz", diff --git a/package.json b/package.json index 1aecc239..ffdfccfb 100644 --- a/package.json +++ b/package.json @@ -39,12 +39,15 @@ "eslint-plugin-eslint-plugin": "^6.4.0", "eslint-plugin-mocha": "^11.1.0", "husky": "^9.1.7", + "prettier": "^3.5.3", "semantic-release": "24.2.5", "vitest": "^3.1.4" }, "scripts": { "lint": "eslint", "lint-fix": "eslint --fix", + "format": "prettier --write .", + "format:check": "prettier --check .", "semantic-release": "semantic-release", "test": "vitest run", "prepare": "husky"