From 1edd2f944252d4bc35fed4ecf91c7994ee7556e0 Mon Sep 17 00:00:00 2001 From: Derrick Mehaffy Date: Mon, 27 Jan 2020 00:56:09 -0700 Subject: [PATCH 1/7] Fix cron reference documentation Signed-off-by: Derrick Mehaffy Based on the Cron-Style listed in `node-schedule`: https://www.npmjs.com/package/node-schedule#cron-style-scheduling --- .../lib/resources/files/config/functions/cron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-generate-new/lib/resources/files/config/functions/cron.js b/packages/strapi-generate-new/lib/resources/files/config/functions/cron.js index 55968ee231..9b9a8a3e9f 100644 --- a/packages/strapi-generate-new/lib/resources/files/config/functions/cron.js +++ b/packages/strapi-generate-new/lib/resources/files/config/functions/cron.js @@ -5,7 +5,7 @@ * to run scheduled jobs. * * The cron format consists of: - * [MINUTE] [HOUR] [DAY OF MONTH] [MONTH OF YEAR] [DAY OF WEEK] [YEAR (optional)] + * [SECOND (optional)] [MINUTE] [HOUR] [DAY OF MONTH] [MONTH OF YEAR] [DAY OF WEEK] * * See more details here: https://strapi.io/documentation/3.0.0-beta.x/concepts/configurations.html#cron-tasks */ From d0c26fef67e973cff1529696a5107183e6f62951 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 27 Jan 2020 09:53:19 +0100 Subject: [PATCH 2/7] Fix main field set to id on mongo Signed-off-by: Alexandre Bodin --- .../services/utils/configuration/metadatas.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/strapi-plugin-content-manager/services/utils/configuration/metadatas.js b/packages/strapi-plugin-content-manager/services/utils/configuration/metadatas.js index 4df369e8e4..6ddd46d457 100644 --- a/packages/strapi-plugin-content-manager/services/utils/configuration/metadatas.js +++ b/packages/strapi-plugin-content-manager/services/utils/configuration/metadatas.js @@ -30,7 +30,9 @@ function createDefaultMainField(schema) { if (!schema) return 'id'; const mainField = Object.keys(schema.attributes).find( - key => schema.attributes[key].type === 'string' && key !== schema.primaryKey + key => + schema.attributes[key].type === 'string' && + !['id', schema.primaryKey].includes(key) ); return mainField || 'id'; From 4f5a0e76799b2186e7e45b62cf76d78599a8d7f7 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Fri, 24 Jan 2020 15:39:14 +0100 Subject: [PATCH 3/7] Cleanup eslint configs Signed-off-by: Alexandre Bodin --- .eslintignore | 6 +- .eslintrc.back.js | 22 ++ .eslintrc.front.js | 132 +++++++++++ .eslintrc.js | 146 ++---------- cypress/plugins/index.js | 2 +- cypress/support/commands.js | 1 + cypress/support/index.js | 8 +- examples/getstarted/package.json | 2 +- package.json | 9 +- .../create-strapi-app/create-strapi-app.js | 2 + packages/strapi-admin/package.json | 2 + .../strapi-connector-bookshelf/package.json | 3 + .../strapi-connector-mongoose/lib/index.js | 1 + packages/strapi-database/package.json | 1 + .../lib/src/components/CircleButton/index.js | 1 + .../src/components/GlobalPagination/index.js | 4 +- .../lib/src/components/HeaderNav/index.js | 2 - .../lib/src/components/ImgPreview/index.js | 6 +- .../lib/src/components/InputCheckbox/index.js | 1 + .../InputCheckboxWithErrors/index.js | 3 +- .../lib/src/components/InputDate/index.js | 6 +- .../src/components/InputDescription/index.js | 1 + .../lib/src/components/InputPassword/index.js | 4 +- .../lib/src/components/InputSelect/index.js | 4 +- .../components/InputSelectWithErrors/index.js | 1 + .../components/InputToggleWithErrors/index.js | 1 + .../src/components/LeftMenuHeader/index.js | 2 +- .../lib/src/components/LeftMenuList/index.js | 2 + .../src/components/LeftMenuSubList/index.js | 1 + .../lib/src/components/ListHeader/index.js | 4 +- .../lib/src/components/PageFooter/index.js | 2 +- packages/strapi-helper-plugin/lib/src/i18n.js | 36 +-- .../lib/src/svgs/Close/index.js | 2 +- .../lib/src/utils/auth.js | 2 +- .../lib/src/utils/cleanData.js | 16 +- .../lib/src/utils/colors.js | 18 +- .../lib/src/utils/request.js | 3 +- .../lib/src/utils/storeData.js | 2 +- .../lib/src/utils/templateObject.js | 4 +- packages/strapi-hook-redis/lib/index.js | 1 - .../test/front/integration/init_specs.js | 1 + .../test/front/integration/listPage_specs.js | 4 +- .../package.json | 1 + .../front/integrationOld/createApi_specs.js | 38 +++- packages/strapi-plugin-email/package.json | 1 + .../hooks/graphql/load-config.js | 1 + packages/strapi-plugin-graphql/package.json | 1 + .../admin/src/components/EditForm/index.js | 1 + .../admin/src/components/Li/components.js | 2 + .../admin/src/components/Li/index.js | 2 + .../admin/src/components/ListHeader/index.js | 3 + .../src/components/PluginInputFile/Label.js | 4 + .../admin/src/containers/ConfigPage/index.js | 2 + .../admin/src/containers/HomePage/actions.js | 1 + .../admin/src/containers/HomePage/index.js | 2 + .../admin/src/containers/HomePage/saga.js | 3 +- .../test/front/integration/login_specs.js | 42 ---- .../test/front/integration/register_specs.js | 49 ---- .../lib/index.js | 2 +- packages/strapi-utils/package.json | 2 - packages/strapi/lib/commands/build.js | 1 + packages/strapi/lib/commands/develop.js | 1 - packages/strapi/lib/commands/generate.js | 2 - packages/strapi/lib/commands/new.js | 2 - packages/strapi/lib/commands/update.js | 150 ++++++++---- packages/strapi/lib/commands/watchAdmin.js | 1 + packages/strapi/lib/utils/success.js | 24 +- yarn.lock | 213 +++++++++++++----- 68 files changed, 602 insertions(+), 420 deletions(-) create mode 100644 .eslintrc.back.js create mode 100644 .eslintrc.front.js delete mode 100644 packages/strapi-plugin-users-permissions/test/front/integration/login_specs.js delete mode 100644 packages/strapi-plugin-users-permissions/test/front/integration/register_specs.js diff --git a/.eslintignore b/.eslintignore index 6b3786a50f..1e5a8d7c81 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,7 +2,9 @@ **/build/** **/dist/** testApp/** -packages/strapi-plugin-users-permissions/admin/** -packages/strapi-plugin-upload/admin/** packages/strapi-generate-plugin/files/admin/src/** +packages/strapi-helper-plugin/** +packages/strapi-plugin-users-permissions/admin/** .eslintrc.js +.eslintrc.front.js +.eslintrc.back.js diff --git a/.eslintrc.back.js b/.eslintrc.back.js new file mode 100644 index 0000000000..e832552319 --- /dev/null +++ b/.eslintrc.back.js @@ -0,0 +1,22 @@ +module.exports = { + extends: [ + 'eslint:recommended', + 'prettier', + 'plugin:import/errors', + 'plugin:import/warnings', + 'plugin:node/recommended', + ], + env: { + es6: true, + node: true, + jest: true, + }, + globals: { + strapi: false, + }, + rules: { + 'node/no-unpublished-require': 0, + 'require-atomic-updates': 0, + 'no-process-exit': 0, + }, +}; diff --git a/.eslintrc.front.js b/.eslintrc.front.js new file mode 100644 index 0000000000..ffa0c91cbb --- /dev/null +++ b/.eslintrc.front.js @@ -0,0 +1,132 @@ +module.exports = { + parser: 'babel-eslint', + extends: [ + 'eslint:recommended', + 'plugin:react/recommended', + 'plugin:redux-saga/recommended', + 'prettier', + ], + plugins: ['react', 'redux-saga', 'react-hooks', 'import', 'jsx-a11y'], + env: { + browser: true, + commonjs: true, + es6: true, + jest: true, + mocha: true, + }, + parserOptions: { + ecmaVersion: 2018, + ecmaFeatures: { + jsx: true, + }, + sourceType: 'module', + }, + globals: { + strapi: false, + window: false, + cy: false, + Cypress: false, + expect: false, + assert: false, + chai: false, + // TODO: put all this in process.env in webpack to avoid having to set them here + REMOTE_URL: true, + BACKEND_URL: true, + PUBLIC_PATH: true, + MODE: true, + NODE_ENV: true, + }, + extends: ['airbnb'], + settings: { + react: { + version: '16.5.2', + }, + }, + rules: { + 'generator-star-spacing': 0, + 'no-console': 0, + 'require-atomic-updates': 0, + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + 'arrow-body-style': 0, + 'arrow-parens': 0, + camelcase: 0, + 'comma-dangle': 0, + 'consistent-return': [ + 2, + { + treatUndefinedAsUnspecified: true, + }, + ], + indent: [ + 2, + 2, + { + flatTernaryExpressions: false, + SwitchCase: 1, + ignoredNodes: [ + 'ConditionalExpression', + "VariableDeclarator[kind='const']", + ], + }, + ], + 'func-names': ['error', 'never'], + 'function-paren-newline': 0, + 'implicit-arrow-linebreak': 0, + 'import/no-extraneous-dependencies': 0, + 'import/no-named-as-default': 0, + 'import/order': 2, + 'jsx-a11y/click-events-have-key-events': 1, + 'max-len': [ + 2, + { + code: 120, + ignoreComments: true, + ignoreUrls: true, + ignoreTrailingComments: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }, + ], + 'newline-before-return': 2, + 'no-confusing-arrow': 0, + 'no-else-return': 1, + 'no-nested-ternary': ['error'], + 'no-return-assign': 0, + 'no-param-reassign': 0, + 'no-plusplus': 0, + 'no-shadow': 0, + 'no-underscore-dangle': 0, + 'no-use-before-define': [ + 'error', + { functions: false, classes: false, variables: false }, + ], + 'object-curly-newline': [2, { multiline: true, consistent: true }], + 'operator-linebreak': 0, + 'padding-line-between-statements': [ + 'error', + { blankLine: 'always', prev: '*', next: 'if' }, + { blankLine: 'any', prev: 'block-like', next: 'if' }, + ], + 'prefer-arrow-callback': 0, + 'prefer-const': 0, + 'prefer-destructuring': 0, + 'prefer-object-spread': 0, + 'prefer-spread': 0, + 'space-before-function-paren': [ + 'error', + { + anonymous: 'never', + named: 'never', + asyncArrow: 'always', + }, + ], + 'react/destructuring-assignment': 0, + 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], + 'react/forbid-prop-types': 0, + 'react/jsx-props-no-spreading': 0, + 'react/jsx-one-expression-per-line': 0, + 'react/state-in-constructor': 0, + 'react/static-property-placement': 0, + }, +}; diff --git a/.eslintrc.js b/.eslintrc.js index 48ff3dbae8..f263479f6e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,140 +1,24 @@ +const frontPaths = [ + 'packages/**/admin/src/**/**/*.js', + 'packages/strapi-helper-plugin/**/*.js', + 'cypress/**/*.js', + 'packages/**/test/front/**/*.js', + 'test/config/front/**/*.js', +]; + module.exports = { - parser: 'babel-eslint', - extends: [ - 'eslint:recommended', - 'plugin:react/recommended', - 'plugin:redux-saga/recommended', - 'prettier', - ], - plugins: ['react', 'redux-saga', 'react-hooks', 'import', 'jsx-a11y'], - env: { - browser: true, - commonjs: true, - es6: true, - node: true, - jest: true, - mocha: true, - }, parserOptions: { ecmaVersion: 2018, - ecmaFeatures: { - jsx: true, - }, - sourceType: 'module', - }, - // all readonly - globals: { - strapi: false, - window: false, - cy: false, - Cypress: false, - expect: false, - assert: false, - chai: false, - // TODO: put all this in process.env in webpack to avoid having to set them here - REMOTE_URL: true, - BACKEND_URL: true, - PUBLIC_PATH: true, - MODE: true, - NODE_ENV: true, - }, - rules: { - 'generator-star-spacing': 0, - 'no-console': 0, - 'require-atomic-updates': 0, - 'react-hooks/rules-of-hooks': 'error', - 'react-hooks/exhaustive-deps': 'warn', - }, - settings: { - react: { - version: '16.5.2', - }, }, overrides: [ { - files: ['packages/**/admin/src/**/**/*.js'], - extends: ['airbnb'], - rules: { - 'arrow-body-style': 0, - 'arrow-parens': 0, - camelcase: 0, - 'comma-dangle': 0, - 'consistent-return': [ - 2, - { - treatUndefinedAsUnspecified: true, - }, - ], - indent: [ - 2, - 2, - { - flatTernaryExpressions: false, - SwitchCase: 1, - ignoredNodes: [ - 'ConditionalExpression', - "VariableDeclarator[kind='const']", - ], - }, - ], - 'func-names': ['error', 'never'], - 'function-paren-newline': 0, - 'implicit-arrow-linebreak': 0, - 'import/no-extraneous-dependencies': 0, - 'import/no-named-as-default': 0, - 'import/order': 2, - 'jsx-a11y/click-events-have-key-events': 1, - 'max-len': [ - 2, - { - code: 120, - ignoreComments: true, - ignoreUrls: true, - ignoreTrailingComments: true, - ignoreStrings: true, - ignoreTemplateLiterals: true, - }, - ], - 'newline-before-return': 2, - 'no-confusing-arrow': 0, - 'no-else-return': 1, - 'no-nested-ternary': ['error'], - 'no-return-assign': 0, - 'no-param-reassign': 0, - 'no-shadow': 0, - 'no-underscore-dangle': 0, - 'no-use-before-define': [ - 'error', - { functions: false, classes: false, variables: false }, - ], - 'object-curly-newline': [2, { multiline: true, consistent: true }], - 'operator-linebreak': 0, - 'padding-line-between-statements': [ - 'error', - { blankLine: 'always', prev: '*', next: 'if' }, - { blankLine: 'any', prev: 'block-like', next: 'if' }, - ], - 'prefer-arrow-callback': 0, - 'prefer-const': 0, - 'prefer-destructuring': 0, - 'prefer-object-spread': 0, - 'prefer-spread': 0, - 'space-before-function-paren': [ - 'error', - { - anonymous: 'never', - named: 'never', - asyncArrow: 'always', - }, - ], - 'react/destructuring-assignment': 0, - 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], - 'react/forbid-prop-types': 0, - 'react/jsx-props-no-spreading': 0, - 'react/jsx-one-expression-per-line': 0, - 'react/state-in-constructor': 0, - 'react/static-property-placement': 0, - }, + files: ['packages/**/*.js', 'test/**/*.js', 'scripts/**/*.js'], + excludedFiles: frontPaths, + ...require('./.eslintrc.back.js'), + }, + { + files: frontPaths, + ...require('./.eslintrc.front.js'), }, ], }; diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 564bbfa77d..df3a5aeeaf 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -11,7 +11,7 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -module.exports = (/*on, config*/) => { +module.exports = (/* on, config */) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config }; diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 3321905882..2dd3acf530 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -162,6 +162,7 @@ Cypress.Commands.add('deleteApi', (model, jwt) => { Cypress.Commands.add('login', () => { cy.createUser(); + return cy .request({ url: `${backendUrl}/admin/auth/local`, diff --git a/cypress/support/index.js b/cypress/support/index.js index de90bec1e8..d3a96af031 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') @@ -28,6 +28,8 @@ Cypress.on('before:browser:launch', (browser = {}, args) => { if (browser.name === 'chrome') { args.push('--disable-site-isolation-trials'); - return args + return args; } -}) \ No newline at end of file + + return args; +}); diff --git a/examples/getstarted/package.json b/examples/getstarted/package.json index fe07a20d7b..1fe4cf7dbf 100644 --- a/examples/getstarted/package.json +++ b/examples/getstarted/package.json @@ -10,7 +10,7 @@ "strapi": "strapi" }, "dependencies": { - "knex": "^0.16.5", + "knex": "^0.20.0", "lodash": "^4.17.5", "mysql": "^2.17.1", "pg": "^7.10.0", diff --git a/package.json b/package.json index 9730062a54..655962bfcd 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@testing-library/react": "^9.1.0", "@testing-library/react-hooks": "^2.0.0", "babel-eslint": "^10.0.0", + "chokidar": "3.3.1", "cross-env": "^5.2.0", "cypress": "3.1.2", "enzyme": "^3.9.0", @@ -16,10 +17,13 @@ "eslint-config-prettier": "^6.2.0", "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-node": "11.0.0", "eslint-plugin-react": "^7.14.0", "eslint-plugin-react-hooks": "^2.0.0", "eslint-plugin-redux-saga": "^1.1.0", "execa": "^1.0.0", + "fs-extra": "8.1.0", + "glob": "7.1.6", "husky": "^3.0.0", "istanbul": "~0.4.2", "jest": "^24.5.0", @@ -31,9 +35,12 @@ "react-test-renderer": "^16.9.0", "request": "^2.87.0", "request-promise-native": "^1.0.7", + "rimraf": "3.0.0", "snyk": "^1.99.0", "wait-on": "^3.2.0", - "yargs": "^13.2.2" + "yargs": "^13.2.2", + "strapi": "3.0.0-beta.18.6", + "strapi-generate-new": "3.0.0-beta.18.6" }, "scripts": { "setup": "yarn && yarn build", diff --git a/packages/create-strapi-app/create-strapi-app.js b/packages/create-strapi-app/create-strapi-app.js index 6842e2a499..5dc9191293 100644 --- a/packages/create-strapi-app/create-strapi-app.js +++ b/packages/create-strapi-app/create-strapi-app.js @@ -37,6 +37,8 @@ program if (projectName === undefined) { console.error('Please specify the of your project'); + + // eslint-disable-next-line no-process-exit process.exit(1); } diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index a843bc1ecf..ae9c0d8936 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -43,6 +43,7 @@ "cross-env": "^5.0.5", "css-loader": "^2.1.1", "duplicate-package-checker-webpack-plugin": "^3.0.0", + "execa": "^1.0.0", "file-loader": "^3.0.1", "font-awesome": "^4.7.0", "friendly-errors-webpack-plugin": "^1.7.0", @@ -55,6 +56,7 @@ "intl": "^1.2.5", "invariant": "^2.2.4", "is-wsl": "^2.0.0", + "lodash": "^4.17.11", "match-sorter": "^4.0.2", "mini-css-extract-plugin": "^0.6.0", "moment": "^2.24.0", diff --git a/packages/strapi-connector-bookshelf/package.json b/packages/strapi-connector-bookshelf/package.json index 63ef28e9f4..d78b7711a5 100644 --- a/packages/strapi-connector-bookshelf/package.json +++ b/packages/strapi-connector-bookshelf/package.json @@ -24,6 +24,9 @@ "rimraf": "^2.6.3", "strapi-utils": "3.0.0-beta.18.6" }, + "peerDependencies": { + "knex": "^0.20.0" + }, "strapi": { "dependencies": [ "knex" diff --git a/packages/strapi-connector-mongoose/lib/index.js b/packages/strapi-connector-mongoose/lib/index.js index f220848054..8b800735de 100644 --- a/packages/strapi-connector-mongoose/lib/index.js +++ b/packages/strapi-connector-mongoose/lib/index.js @@ -58,6 +58,7 @@ module.exports = function(strapi) { useUnifiedTopology, } = connection.settings; + // eslint-disable-next-line node/no-deprecated-api const uriOptions = uri ? url.parse(uri, true).query : {}; const { authenticationDatabase, ssl, debug } = _.defaults( connection.options, diff --git a/packages/strapi-database/package.json b/packages/strapi-database/package.json index 42379d194d..d544854644 100644 --- a/packages/strapi-database/package.json +++ b/packages/strapi-database/package.json @@ -28,6 +28,7 @@ }, "license": "MIT", "dependencies": { + "lodash": "^4.17.11", "verror": "^1.10.0" } } diff --git a/packages/strapi-helper-plugin/lib/src/components/CircleButton/index.js b/packages/strapi-helper-plugin/lib/src/components/CircleButton/index.js index ddb783f2a8..186f6a368e 100644 --- a/packages/strapi-helper-plugin/lib/src/components/CircleButton/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/CircleButton/index.js @@ -24,6 +24,7 @@ const CircleButton = styled.button` } `; } + return css` &:after { content: '\f067'; diff --git a/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js b/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js index c0d85599c2..edc0292868 100644 --- a/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js @@ -136,7 +136,7 @@ class GlobalPagination extends React.Component { onClick={this.handlePreviousPageClick} disabled={this.isFirstPage()} > - +