From a31adb8f3cea4839e8a984514095238a64e30493 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sun, 20 Jan 2019 21:30:24 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=81=20Add=20Prettier=20configs=20for?= =?UTF-8?q?=20Standard=20&=20Vue=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 36 ++++++++++++++++++++++++++++++++---- code-style.js | 16 ++-------------- package-lock.json | 15 +++++++++++++++ package.json | 10 +++++++++- vue.js | 2 +- 5 files changed, 59 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d798271..0836da6 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,44 @@ Install the conventions by running: -```sh +```shell npm install --save-dev eslint @zazen/eslint-config ``` -Then add the extends to your `.eslintrc.js`: +Add the extends to your `.eslintrc.js`: ```js { - extends: '@zazen/eslint-config', - rules: { /* … */ } + extends: ['@zazen/eslint-config'], + rules: { /* … */ } +} +``` + +Add the Prettier settings to your `package.json`: + +```json +"prettier": { + "arrowParens": "always", + "semi": false, + "singleQuote": true, + "tabWidth": 4 +}, +``` + +### Vue.js projects + +Install the optionalDependency `eslint-plugin-vue`: + +```shell +npm install --save-dev eslint-plugin-vue +``` + +Extend the Vue-specific settings in `.eslintrc.js`: + +```js +{ + extends: ['@zazen/eslint-config', '@zazen/eslint-config/vue'], + rules: { /* … */ } } ``` diff --git a/code-style.js b/code-style.js index f5615f1..60f57e5 100644 --- a/code-style.js +++ b/code-style.js @@ -2,20 +2,8 @@ * Enforce a consistent code style. */ module.exports = { + extends: ['prettier', 'prettier/standard'], rules: { - 'array-bracket-spacing': ['error', 'never'], - 'arrow-parens': ['error', 'always'], - 'comma-dangle': [ - 'error', - { - arrays: 'always-multiline', - objects: 'always-multiline', - imports: 'always-multiline', - exports: 'always-multiline', - functions: 'always-multiline', - }, - ], - indent: ['error', 4], - 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], + // 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], }, } diff --git a/package-lock.json b/package-lock.json index 9f87ec4..e20be2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1269,6 +1269,21 @@ } } }, + "eslint-config-prettier": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-3.6.0.tgz", + "integrity": "sha512-ixJ4U3uTLXwJts4rmSVW/lMXjlGwCijhBJHk8iVqKKSifeI0qgFEfWl8L63isfc8Od7EiBALF6BX3jKLluf/jQ==", + "requires": { + "get-stdin": "^6.0.0" + }, + "dependencies": { + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==" + } + } + }, "eslint-config-standard": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-12.0.0.tgz", diff --git a/package.json b/package.json index 30ab960..9edbfc5 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "@zazen/eslint-config", "description": "Lint JavaScript, free of weariness and confusion", - "license": "MIT", + "license": "ISC", "author": "Jeff (https://tidaltheory.co)", "homepage": "https://github.com/stormwarning/zazen-eslint-config", "repository": "stormwarning/zazen-eslint-config", "version": "0.3.0", "scripts": { + "eslint-check": "eslint --print-config . | eslint-config-prettier-check", "lint": "npm-run-all lint:*", "lint:markdown": "remark . -qo", "lint:scripts": "prettier-eslint '**/*.js' --write --list-different", @@ -17,6 +18,7 @@ }, "dependencies": { "babel-eslint": "^10.0.1", + "eslint-config-prettier": "^3.6.0", "eslint-config-standard": "^12.0.0", "eslint-plugin-import": "^2.14.0", "eslint-plugin-node": "^8.0.0", @@ -52,6 +54,12 @@ "git add" ] }, + "prettier": { + "arrowParens": "always", + "semi": false, + "singleQuote": true, + "tabWidth": 4 + }, "remarkConfig": { "plugins": [ "preset-lint-markdown-style-guide", diff --git a/vue.js b/vue.js index b4d9d1d..2596d27 100644 --- a/vue.js +++ b/vue.js @@ -2,5 +2,5 @@ * Vuejs project rules. */ module.exports = { - extends: ['plugin:vue/recommended'], + extends: ['plugin:vue/recommended', 'prettier/vue'], }