From 038f0cc4e4ed67efacf189bd4f6ed90649d7ae92 Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Mon, 10 Oct 2016 07:21:12 +0200 Subject: [PATCH] Changed: base theme now provides a less strict eslint config (only eslint + eslint-plugin-react recommended rules) Closes #631 --- CHANGELOG.md | 3 ++ docs/content/docs/advanced/good-practices.md | 45 +++++--------------- package.json | 2 - src/bin/commands/setup/template.js | 31 ++++++-------- 4 files changed, 28 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a43fc5ef6..e4220c731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +- Changed: base theme now provides a less strict eslint config + (only eslint + eslint-plugin-react recommended rules) + # 0.17.8 - 2016-10-08 - Fixed: Service worker file was imported relatively, which only works at the diff --git a/docs/content/docs/advanced/good-practices.md b/docs/content/docs/advanced/good-practices.md index d58615676..1545a36c7 100644 --- a/docs/content/docs/advanced/good-practices.md +++ b/docs/content/docs/advanced/good-practices.md @@ -4,55 +4,32 @@ title: Good practices ## Linting -Our phenomic-theme-base comes with best-in-class tools for linting both JavaScript -and CSS. Linting your code is a good practice because it reduces the probability +Our base theme comes with best-in-class tools for linting both JavaScript +and CSS. +Linting your code is a good practice because it reduces the probability of errors and helps to enforce code consistency. ## JavaScript Linting -[ESLint](http://eslint.org/) is a must have JavaScript linter; the default -phenomic-theme-base provides you with a nice [standard set of rules](https://github.com/MoOx/eslint-config-i-am-meticulous) -for ES2015+ & React. +[ESLint](http://eslint.org/) is a must have JavaScript linter. +The base theme provides you with a standard set of rules for ES2015+ & React +(via eslint and eslint-plugin-react recommended config). -That being said, you might want less rules (or semicolons). +### Alternative config -### Less strict JavaScript linting - -To remove the default config, you can replace the ``eslintConfig`` in your -``package.json`` with the following config: - -```json -{ - "eslintConfig": { - "parser": "babel-eslint", - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", - "ecmaFeatures": { - "experimentalObjectRestSpread": true - }, - }, - "env": { - "node": true, - "browser": true, - "es6": true - } - } -} -``` - -In this example, we used ``eslint:recommended``, but feel free to use one of the +Feel free to use one of the [many existing configs](https://www.npmjs.com/search?q=eslint-config). + Here are some "popular" configs: - https://github.com/feross/eslint-config-standard - https://github.com/feross/eslint-config-standard-react - https://github.com/sindresorhus/eslint-config-xo - https://github.com/sindresorhus/eslint-config-xo-react +- https://github.com/MoOx/eslint-config-i-am-meticulous If you switch to one of these configurations, you might get some linting errors. -To fix this, simply use the following command: +To fix most of this errors, use the following command: ```sh ./node_modules/.bin/eslint --fix . diff --git a/package.json b/package.json index a3fac06be..bc2035aac 100644 --- a/package.json +++ b/package.json @@ -151,9 +151,7 @@ "babel-preset-stage-1": "^6.13.0", "css-loader": "^0.25.0", "eslint": "^3.7.1", - "eslint-config-i-am-meticulous": "^5.0.2", "eslint-loader": "^1.5.0", - "eslint-plugin-import": "^2.0.0", "eslint-plugin-react": "^6.3.0", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.9.0", diff --git a/src/bin/commands/setup/template.js b/src/bin/commands/setup/template.js index bce71c4b5..4f1f6bdaf 100644 --- a/src/bin/commands/setup/template.js +++ b/src/bin/commands/setup/template.js @@ -73,24 +73,21 @@ const template = { "eslintConfig": { "parser": "babel-eslint", "extends": [ - "eslint-config-i-am-meticulous/react", + "eslint:recommended", + "plugin:react/recommended", ], - "rules": { - "import/order": "off", - "import/newline-after-import": "off", - "import/imports-first": "off", - "import/no-mutable-exports": "off", - "import/max-dependencies": "off", - "import/default": "off", - "import/no-namespace": "off", - "import/namespace": "off", - "react/jsx-indent": "off", - "import/no-named-as-default": "off", - "import/no-extraneous-dependencies": "off", - "import/no-duplicates": "off", - "react/no-children-prop": "off", - "react/jsx-no-target-blank": "off", - "import/no-unresolved": "off", + "env": { + "browser": true, + "node": true, + }, + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true, + "generators": true, + "experimentalObjectRestSpread": true, + }, }, }, "stylelint": {