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/docs/3.0.0-beta.x/concepts/webhooks.md b/docs/3.0.0-beta.x/concepts/webhooks.md index bbf7deb5f9..43d4d1ef00 100644 --- a/docs/3.0.0-beta.x/concepts/webhooks.md +++ b/docs/3.0.0-beta.x/concepts/webhooks.md @@ -245,7 +245,7 @@ You can configure these global headers by updating the file at `./config/environ { "webhooks": { "defaultHeaders": { - "Authroization": "Bearer my-very-secured-token" + "Authorization": "Bearer my-very-secured-token" } } } @@ -259,7 +259,7 @@ You can configure these global headers by updating the file at `./config/environ { "webhooks": { "defaultHeaders": { - "Authroization": "Bearer ${ process.env.WEBHOOK_TOKEN }" + "Authorization": "Bearer ${ process.env.WEBHOOK_TOKEN }" } } } diff --git a/docs/3.0.0-beta.x/plugins/upload.md b/docs/3.0.0-beta.x/plugins/upload.md index fb3dd2be16..6fdf525446 100644 --- a/docs/3.0.0-beta.x/plugins/upload.md +++ b/docs/3.0.0-beta.x/plugins/upload.md @@ -213,7 +213,7 @@ And for your files, they have to be prefixed by `files`. Example here with cover attribute `files.cover`. ::: tip -If you want to upload files for a component, you will have to specify the inidex of the item you wan to add the file. +If you want to upload files for a component, you will have to specify the index of the item you want to add the file. Example `files.my_component_name[the_index].attribute_name` ::: 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/admin/src/translations/pt-BR.json b/packages/strapi-admin/admin/src/translations/pt-BR.json index 9ba52f2826..6f21c898d8 100644 --- a/packages/strapi-admin/admin/src/translations/pt-BR.json +++ b/packages/strapi-admin/admin/src/translations/pt-BR.json @@ -213,5 +213,9 @@ "Auth.link.forgot-password": "Esqueceu sua senha?", "Auth.link.ready": "Pronto para entrar?", "app.containers.App.notification.error.init": "Ocorreu um erro ao solicitar a API", - "components.Input.error.password.noMatch": "As senhas não conferem" + "components.Input.error.password.noMatch": "As senhas não conferem", + "form.button.done": "Terminar", + "form.button.finish": "Finalizar", + "notification.form.error.fields": "O formulário contém alguns erros", + "global.prompt.unsaved": "Você tem certeza que deseja sair desta página? Todas as suas modificacões serão perdidas" } 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-connector-mongoose/lib/mount-models.js b/packages/strapi-connector-mongoose/lib/mount-models.js index a50380405b..fd80ce5459 100644 --- a/packages/strapi-connector-mongoose/lib/mount-models.js +++ b/packages/strapi-connector-mongoose/lib/mount-models.js @@ -229,7 +229,8 @@ module.exports = ({ models, target, plugin = false }, ctx) => { const refToStrapiRef = obj => { const ref = obj.ref; - let plainData = typeof ref.toJSON === 'function' ? ref.toJSON() : ref; + let plainData = + ref && typeof ref.toJSON === 'function' ? ref.toJSON() : ref; if (typeof plainData !== 'object') return ref; 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-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 */ 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()} > - +