From 30528f40eccee069ad607de9bebbe48984d2c854 Mon Sep 17 00:00:00 2001 From: soupette Date: Wed, 2 May 2018 11:01:27 +0200 Subject: [PATCH] Add eslint to strapi-admin backend --- .../src/components/LeftMenuLink/index.js | 24 ++++++++++++------- .../admin/src/components/Logout/index.js | 2 +- .../admin/src/components/PluginCard/index.js | 1 + packages/strapi-admin/package.json | 6 +++-- packages/strapi-helper-plugin/package.json | 2 +- .../package.json | 2 +- scripts/setup.js | 1 + 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js b/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js index ab9dc5d67d..5a36b8e12b 100755 --- a/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js +++ b/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js @@ -14,21 +14,29 @@ import en from 'translations/en.json'; import styles from './styles.scss'; -class LeftMenuLink extends React.Component { // eslint-disable-line react/prefer-stateless-function +class LeftMenuLink extends React.Component { + // eslint-disable-line react/prefer-stateless-function render() { // We need to create our own active url checker, // because of the two levels router. - const isLinkActive = startsWith(window.location.pathname.replace('/admin', ''), this.props.destination); - const plugin = this.props.source !== 'content-manager' && this.props.source !== '' ? - (
- {upperFirst(this.props.source.split('-').join(' '))} -
) : ''; + const isLinkActive = startsWith( + window.location.pathname.replace('/admin', ''), + this.props.destination, + ); + const plugin = + this.props.source !== 'content-manager' && this.props.source !== '' ? ( +
+ {upperFirst(this.props.source.split('-').join(' '))} +
+ ) : ( + '' + ); // Check if messageId exists in en locale to prevent warning messages const content = en[this.props.label] ? ( - + {content} {plugin} diff --git a/packages/strapi-admin/admin/src/components/Logout/index.js b/packages/strapi-admin/admin/src/components/Logout/index.js index 469f954c2b..c97d9a9c35 100644 --- a/packages/strapi-admin/admin/src/components/Logout/index.js +++ b/packages/strapi-admin/admin/src/components/Logout/index.js @@ -36,7 +36,7 @@ class Logout extends React.Component { // eslint-disable-line react/prefer-state {get(auth.getUserInfo(), 'username')} - + diff --git a/packages/strapi-admin/admin/src/components/PluginCard/index.js b/packages/strapi-admin/admin/src/components/PluginCard/index.js index d48067bec0..83f28ff732 100644 --- a/packages/strapi-admin/admin/src/components/PluginCard/index.js +++ b/packages/strapi-admin/admin/src/components/PluginCard/index.js @@ -20,6 +20,7 @@ import logoTShirt from 'assets/images/logo-t-shirt.svg'; import styles from './styles.scss'; import Screenshot from './screenshot.png'; +/* eslint-disable react/no-unused-state */ class PluginCard extends React.Component { state = { isOpen: false, boostrapCol: 'col-lg-4' }; diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 9eac64685b..bfaaade8c7 100755 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -18,9 +18,10 @@ "prestart": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development PORT=4000 IS_ADMIN=true node ./node_modules/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js", "start": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development PORT=4000 IS_ADMIN=true node ./node_modules/strapi-helper-plugin/lib/server", "generate": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/plop --plopfile ./node_modules/strapi-helper-plugin/lib/internals/generators/index.js", - "lint": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/eslint --ignore-path ./admin/.gitignore --ignore-pattern build --config ./node_modules/strapi-helper-plugin/lib/internals/eslint/.eslintrc.json admin", + "lint:front": "node ./node_modules/strapi-lint/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern '/admin/build/' --config ./node_modules/strapi-lint/lib/internals/eslint/front/.eslintrc.json admin", + "lint:back": "node ./node_modules/strapi-lint/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern '/admin/build/' --config ./node_modules/strapi-lint/lib/internals/eslint/back/.eslintrc.json controllers config services", "prettier": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/prettier --single-quote --trailing-comma es5 --write \"{admin,__{tests,mocks}__}/**/*.js\"", - "test": "npm run lint", + "test": "npm run lint:front && npm run lint:back", "prepublishOnly": "npm run build", "setup": "node ./scripts/setup.js", "presetup": "node ./scripts/preSetup.js" @@ -33,6 +34,7 @@ "devDependencies": { "sanitize.css": "^4.1.0", "strapi-helper-plugin": "3.0.0-alpha.12", + "strapi-lint": "3.0.0-alpha.12", "strapi-utils": "3.0.0-alpha.12" }, "author": { diff --git a/packages/strapi-helper-plugin/package.json b/packages/strapi-helper-plugin/package.json index 493f883525..80c9bfe1c6 100755 --- a/packages/strapi-helper-plugin/package.json +++ b/packages/strapi-helper-plugin/package.json @@ -118,4 +118,4 @@ "webpack-hot-middleware": "^2.18.2", "whatwg-fetch": "^2.0.3" } -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json index f3a850bdcb..ef6bbaea63 100755 --- a/packages/strapi-plugin-content-manager/package.json +++ b/packages/strapi-plugin-content-manager/package.json @@ -49,4 +49,4 @@ "npm": ">= 5.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/scripts/setup.js b/scripts/setup.js index c27432359b..938470e7ec 100755 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -79,6 +79,7 @@ watcher('📦 Linking strapi-helper-plugin...', 'npm link'); shell.cd('../strapi-admin'); watcher('', 'npm install ../strapi-helper-plugin --no-optional'); watcher('', 'npm install ../strapi-utils --no-optional'); +watcher('', 'npm install ../strapi-lint --no-optional'); shell.rm('-f', 'package-lock.json'); // Without these line Travis failed.