diff --git a/.eslintrc.js b/.eslintrc.js index 5212d550ab..87a601504e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -47,4 +47,22 @@ module.exports = { version: '16.5.2', }, }, + overrides: [ + { + files: ['**/admin/**', '**/strapi-helper-plugin/**'], + rules: { + 'redux-saga/no-unhandled-errors': 1, + 'react/no-unescaped-entities': 1, + 'react/prop-types': 1, + 'react/jsx-no-target-blank': 1, + 'react/no-direct-mutation-state': 1, + 'react/display-name': 1, + 'react/jsx-no-target-blank': 1, + 'no-unused-vars': 1, + 'no-undef': 1, + 'no-dupe-keys': 1, + 'no-irregular-whitespace': 1, + }, + }, + ], }; diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index fd170fba69..564bbfa77d 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 037f0b2d3a..3321905882 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -25,7 +25,6 @@ // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) const stringify = JSON.stringify; const backendUrl = Cypress.config('backendUrl'); -const serverRestartDelay = Cypress.config('serverRestartDelay'); const WAIT_ON_CMD = `wait-on ${backendUrl}`; @@ -180,7 +179,7 @@ Cypress.Commands.add('login', () => { }); }); -Cypress.Commands.add('seedData', (model, jwt, source = null) => { +Cypress.Commands.add('seedData', (model, jwt) => { return cy.fixture(`seeds/${model}.json`).then(seed => { seed.forEach(body => { cy.request({ diff --git a/examples/getstarted/exports/graphql/schema.graphql b/examples/getstarted/exports/graphql/schema.graphql index f7af0b2c51..935c43a9a7 100644 --- a/examples/getstarted/exports/graphql/schema.graphql +++ b/examples/getstarted/exports/graphql/schema.graphql @@ -148,9 +148,6 @@ input InputID { id: ID! } -""" -The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). -""" scalar JSON """The `Long` scalar type represents 52-bit integers""" diff --git a/packages/strapi-generate-plugin/lib/index.js b/packages/strapi-generate-plugin/lib/index.js index 67d137d55f..9404c2cdf6 100644 --- a/packages/strapi-generate-plugin/lib/index.js +++ b/packages/strapi-generate-plugin/lib/index.js @@ -20,46 +20,42 @@ module.exports = { before: require('./before'), targets: { 'plugins/:humanizeId/.gitignore': { - copy: 'gitignore' + copy: 'gitignore', }, // Use the default `controller` file as a template for // every generated controller. 'plugins/:humanizeId/controllers/:filename': { - template: 'controller.template' + template: 'controller.template', }, // every generated controller. 'plugins/:humanizeId/services/:filename': { - template: 'service.template' + template: 'service.template', }, // Generate routes. 'plugins/:humanizeId/config/routes.json': { - jsonfile: routesJSON + jsonfile: routesJSON, }, // Main package. 'plugins/:humanizeId/package.json': { - jsonfile: packageJSON + jsonfile: packageJSON, }, // Copy dot files. 'plugins/:humanizeId/.editorconfig': { - copy: 'editorconfig' - }, - - 'plugins/:humanizeId/.gitignore': { - copy: 'gitignore' + copy: 'editorconfig', }, 'plugins/:humanizeId/.gitattributes': { - copy: 'gitattributes' + copy: 'gitattributes', }, // Copy Markdown files with some information. 'plugins/:humanizeId/README.md': { - template: 'README.md' + template: 'README.md', }, - } + }, }; diff --git a/packages/strapi-helper-plugin/lib/src/app.js b/packages/strapi-helper-plugin/lib/src/app.js index 2ed126763d..d0168e98e6 100644 --- a/packages/strapi-helper-plugin/lib/src/app.js +++ b/packages/strapi-helper-plugin/lib/src/app.js @@ -7,7 +7,7 @@ /* eslint-disable */ // Don't move this line! -import './public-path.js'; // eslint-disable-line import/extensions +// import './public-path.js'; // eslint-disable-line import/extensions import React from 'react'; // import Loadable from 'react-loadable'; diff --git a/packages/strapi-helper-plugin/lib/src/public-path.js b/packages/strapi-helper-plugin/lib/src/public-path.js index 22d20f2c57..518a786b87 100644 --- a/packages/strapi-helper-plugin/lib/src/public-path.js +++ b/packages/strapi-helper-plugin/lib/src/public-path.js @@ -1,13 +1,13 @@ -const pluginPkg = require('../../../../package.json'); -const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, ''); -const publicPath = `plugins/${pluginId}/`; +// const pluginPkg = require('../../../../package.json'); +// const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, ''); +// const publicPath = `plugins/${pluginId}/`; -__webpack_public_path__ = (() => { - if (window.location.port === '4000') { - return `${window.location.origin}/`; - } else if (strapi.mode === 'backend') { - return `${strapi.backendURL}/${publicPath}`; - } +// __webpack_public_path__ = (() => { +// if (window.location.port === '4000') { +// return `${window.location.origin}/`; +// } else if (strapi.mode === 'backend') { +// return `${strapi.backendURL}/${publicPath}`; +// } - return `${(strapi.remoteURL).replace(window.location.origin, '')}/${publicPath}`; -})(); +// return `${(strapi.remoteURL).replace(window.location.origin, '')}/${publicPath}`; +// })(); diff --git a/packages/strapi-plugin-content-manager/test/front/integration/createPage_specs.js b/packages/strapi-plugin-content-manager/test/front/integration/createPage_specs.js index 1a29f472ff..64be13f5fc 100644 --- a/packages/strapi-plugin-content-manager/test/front/integration/createPage_specs.js +++ b/packages/strapi-plugin-content-manager/test/front/integration/createPage_specs.js @@ -1,10 +1,9 @@ let jwt; -let userId; -const animDelay = Cypress.config('animDelay'); + const frontEndUrl = Cypress.config('baseUrl'); const frontLoadingDelay = Cypress.config('frontLoadingDelay'); const backendUrl = Cypress.config('backendUrl'); -const pluginUrl = `${frontEndUrl}/admin/plugins/content-manager`; + const getCreateRedirectUrl = (model, sort = '_id') => { return `${frontEndUrl}/admin/plugins/content-manager/${model}/create?redirectUrl=/plugins/content-manager/${model}?_limit=10&_page=1&_sort=${sort}&source=content-manager`; }; @@ -24,17 +23,17 @@ describe('Testing Content Manager createPages', function() { Cypress.Commands.add('ctmTagLink', () => { return cy.get( - 'a[href="/admin/plugins/content-manager/tag?source=content-manager"]', + 'a[href="/admin/plugins/content-manager/tag?source=content-manager"]' ); }); Cypress.Commands.add('ctmProductLink', () => { return cy.get( - 'a[href="/admin/plugins/content-manager/product?source=content-manager"]', + 'a[href="/admin/plugins/content-manager/product?source=content-manager"]' ); }); Cypress.Commands.add('ctmCategoryLink', () => { return cy.get( - 'a[href="/admin/plugins/content-manager/category?source=content-manager"]', + 'a[href="/admin/plugins/content-manager/category?source=content-manager"]' ); }); Cypress.Commands.add('ctmAddButton', () => { @@ -86,7 +85,6 @@ describe('Testing Content Manager createPages', function() { cy.login() .then(data => { jwt = data.jwt; - userId = data.user._id || data.user.id; }) .visit('/admin') .wait(frontLoadingDelay) @@ -227,7 +225,6 @@ describe('Testing Content Manager createPages', function() { cy.login() .then(data => { jwt = data.jwt; - userId = data.user._id || data.user.id; return data.jwt; }) @@ -245,7 +242,6 @@ describe('Testing Content Manager createPages', function() { cy.login() .then(data => { jwt = data.jwt; - userId = data.user._id || data.user.id; return data.jwt; }) @@ -257,7 +253,7 @@ describe('Testing Content Manager createPages', function() { it('Should create a product and link several tags and 1 category', () => { cy.server(); cy.route( - `${backendUrl}/content-manager/explorer/tag?_limit=10&_start=0&_sort=name:ASC&source=content-manager`, + `${backendUrl}/content-manager/explorer/tag?_limit=10&_start=0&_sort=name:ASC&source=content-manager` ).as('getTags'); cy.ctmProductLink() .click() @@ -343,7 +339,7 @@ describe('Testing Content Manager createPages', function() { .click() .wait(1000) .get( - 'ul#sortableListOfproducts > li:nth-child(1) > div:nth-child(2) > img', + 'ul#sortableListOfproducts > li:nth-child(1) > div:nth-child(2) > img' ) .click() .submitForm() @@ -364,10 +360,10 @@ describe('Testing Content Manager createPages', function() { it('Should add several products to category french food', () => { cy.server(); cy.route( - `${backendUrl}/content-manager/explorer/category?_limit=10&_start=0&_sort=_id:ASC&source=content-manager`, + `${backendUrl}/content-manager/explorer/category?_limit=10&_start=0&_sort=_id:ASC&source=content-manager` ).as('getCategories'); cy.route( - `${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=_id:ASC&source=content-manager`, + `${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=_id:ASC&source=content-manager` ).as('getProducts'); const product = { name: 'MacBook', @@ -408,7 +404,7 @@ describe('Testing Content Manager createPages', function() { expect(children[0].innerText.trim()).to.equal('product1'); }) .get( - 'ul#sortableListOfproducts > li:nth-child(1) > div:nth-child(2) > img', + 'ul#sortableListOfproducts > li:nth-child(1) > div:nth-child(2) > img' ) .click() .get('input#products') diff --git a/packages/strapi-plugin-content-manager/test/front/integration/init_specs.js b/packages/strapi-plugin-content-manager/test/front/integration/init_specs.js index 2ac0b9c8da..ee786a9e7e 100644 --- a/packages/strapi-plugin-content-manager/test/front/integration/init_specs.js +++ b/packages/strapi-plugin-content-manager/test/front/integration/init_specs.js @@ -1,8 +1,6 @@ let jwt; -let userId; const animDelay = Cypress.config('animDelay'); const backendUrl = Cypress.config('backendUrl'); -const frontEndUrl = Cypress.config('baseUrl'); const frontLoadingDelay = Cypress.config('frontLoadingDelay'); const links = { Category: '/admin/plugins/content-manager/category?source=content-manager', @@ -11,7 +9,6 @@ const links = { Tag: '/admin/plugins/content-manager/tag?source=content-manager', User: '/admin/plugins/content-manager/user?source=users-permissions', }; -const pluginUrl = `${frontEndUrl}/admin/plugins/content-manager`; describe('Testing build and schema core_store', () => { before(() => { @@ -34,40 +31,38 @@ describe('Testing build and schema core_store', () => { cy.login() .then(data => { jwt = data.jwt; - userId = data.user._id || data.user.id; }) .visit('/admin') .wait(frontLoadingDelay); }); - + it('Should visit all list pages without any errors', () => { cy.server(); cy.route(`${backendUrl}/content-manager/models`).as('initCTM'); cy.get(`a[href="${links.settings}"]`) .click() .wait('@initCTM'); - + // Check all list views are rendered without any error for (let i = 0; i < 4; i++) { Object.keys(links).forEach(link => { const name = link === 'settings' ? 'Content Manager' : link; - + cy.get(`a[href="${links[link]}"]`) .click() .get('h1') .should('have', name); }); } - }); - + it('Should visit all views once without any errors', () => { cy.server(); cy.route(`${backendUrl}/content-manager/models`).as('initCTM'); cy.get(`a[href="${links.settings}"]`) .click() .wait('@initCTM'); - + // Testing errors related to reactstrap cy.get('#cancelChanges') .click() @@ -76,7 +71,6 @@ describe('Testing build and schema core_store', () => { .should('be.visible') .type('{esc}'); - // Test setting view Object.keys(links).forEach(link => { if (link !== 'settings') { @@ -88,7 +82,7 @@ describe('Testing build and schema core_store', () => { .click(); } }); - + Object.keys(links).forEach(link => { if (link !== 'settings') { cy.get(`a[href="${links[link]}"]`) diff --git a/packages/strapi-plugin-content-manager/test/front/integration/listPage_specs.js b/packages/strapi-plugin-content-manager/test/front/integration/listPage_specs.js index cad573a2d3..afe8fcd726 100644 --- a/packages/strapi-plugin-content-manager/test/front/integration/listPage_specs.js +++ b/packages/strapi-plugin-content-manager/test/front/integration/listPage_specs.js @@ -1,10 +1,7 @@ let jwt; -let userId; const animDelay = Cypress.config('animDelay'); -const frontEndUrl = Cypress.config('baseUrl'); const frontLoadingDelay = Cypress.config('frontLoadingDelay'); const backendUrl = Cypress.config('backendUrl'); -const pluginUrl = `${frontEndUrl}/admin/plugins/content-manager`; describe('Testing Content Manager ListPages', function() { before(() => { @@ -12,16 +9,14 @@ describe('Testing Content Manager ListPages', function() { .then(data => { jwt = data.jwt; - return cy - .createCTMApis(data.jwt) - .then(() => jwt); + return cy.createCTMApis(data.jwt).then(() => jwt); }) .then(jwt => { cy.seedData('product', jwt); }) .wait(1000); }); - + after(() => { cy.deleteAllModelData('product', jwt); cy.deleteApi('tag', jwt) @@ -32,16 +27,17 @@ describe('Testing Content Manager ListPages', function() { context('Testing sorting options', () => { beforeEach(() => { cy.login() - .then(data => { - jwt = data.jwt; - userId = data.user._id || data.user.id; - }) - .visit('/admin') - .wait(frontLoadingDelay); + .then(data => { + jwt = data.jwt; + }) + .visit('/admin') + .wait(frontLoadingDelay); }); it('Should have the Id default sort', () => { - cy.get(`a[href="/admin/plugins/content-manager/product?source=content-manager"]`) + cy.get( + `a[href="/admin/plugins/content-manager/product?source=content-manager"]` + ) .click() .wait(frontLoadingDelay); @@ -54,14 +50,23 @@ describe('Testing Content Manager ListPages', function() { it('Should change the default sort of product to name ASC then name DESC', () => { cy.server(); - cy.route(`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=_id:ASC&source=content-manager`).as('getProduct'); - cy.route(`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=name:ASC&source=content-manager`).as('getSortByNameASC'); - cy.route(`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=name:DESC&source=content-manager`).as('getSortByNameDESC'); + cy.route( + `${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=_id:ASC&source=content-manager` + ).as('getProduct'); + cy.route( + `${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=name:ASC&source=content-manager` + ).as('getSortByNameASC'); + cy.route( + `${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=name:DESC&source=content-manager` + ).as('getSortByNameDESC'); - cy.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]') + cy.get( + 'a[href="/admin/plugins/content-manager/product?source=content-manager"]' + ) .click() .wait('@getProduct') - .get('tr > th:nth-child(3) > span').as('getName') + .get('tr > th:nth-child(3) > span') + .as('getName') .click(); cy.wait('@getSortByNameASC') @@ -70,10 +75,10 @@ describe('Testing Content Manager ListPages', function() { .should('be.visible') .invoke('attr', 'class') .should('includes', 'iconAsc') - .get('tbody > tr:nth-child(1) > td:nth-child(3)').as('firstResult') + .get('tbody > tr:nth-child(1) > td:nth-child(3)') + .as('firstResult') .should('have.text', 'name'); - cy.get('@getName') .click() .wait('@getSortByNameDESC') @@ -91,26 +96,31 @@ describe('Testing Content Manager ListPages', function() { .click() .get('#product') .click() - .get('select[name="product\.defaultSort"]').as('defaultSort') + .get('select[name="product.defaultSort"]') + .as('defaultSort') .select('name') .should('have.value', 'name') - .get('select[name="product\.sort"]').as('sortOption') + .get('select[name="product.sort"]') + .as('sortOption') .select('DESC') .should('have.value', 'DESC') .submitForm() .get('#ctaConfirm') .click() .wait(frontLoadingDelay) - .get('a[href="/admin/plugins/content-manager/product?source=content-manager"]') + .get( + 'a[href="/admin/plugins/content-manager/product?source=content-manager"]' + ) .click() .wait(frontLoadingDelay) - .get('tr > th:nth-child(3) > span').as('getName') + .get('tr > th:nth-child(3) > span') + .as('getName') .children('i') .invoke('attr', 'class') .should('includes', 'iconDesc') .get('tbody > tr:nth-child(1) > td:nth-child(3)') .should('have.text', 'name1'); - + // Set it back to normal cy.get('a[href="/admin/plugins/content-manager/ctm-configurations"]') .click() @@ -126,7 +136,9 @@ describe('Testing Content Manager ListPages', function() { .get('#ctaConfirm') .click() .wait(frontLoadingDelay) - .get('a[href="/admin/plugins/content-manager/product?source=content-manager"]') + .get( + 'a[href="/admin/plugins/content-manager/product?source=content-manager"]' + ) .click() .wait(frontLoadingDelay) .get('tr > th:nth-child(2) > span') @@ -139,32 +151,37 @@ describe('Testing Content Manager ListPages', function() { context('Testing filters', () => { beforeEach(() => { cy.login() - .then(data => { - jwt = data.jwt; - userId = data.user._id || data.user.id; - }) - .visit('/admin') - .wait(frontLoadingDelay); + .then(data => { + jwt = data.jwt; + }) + .visit('/admin') + .wait(frontLoadingDelay); }); it('Should apply filters for product data', () => { - cy.get(`a[href="/admin/plugins/content-manager/product?source=content-manager"]`) + cy.get( + `a[href="/admin/plugins/content-manager/product?source=content-manager"]` + ) .click() .wait(frontLoadingDelay); - cy.get('button#addFilterCTA').as('toggleFilter') + cy.get('button#addFilterCTA') + .as('toggleFilter') .click() .wait(animDelay) - .get('div#filterPickWrapper').as('filterWrapper') + .get('div#filterPickWrapper') + .as('filterWrapper') .children('div') .should('have.length', 1); - - cy.get('input[name="0\.value"]') + + cy.get('input[name="0.value"]') .type('name') .get('button#newFilter') .click() - .get('select[name="1\.attr"]') + .get('select[name="1.attr"]') .select('bool') - .get('button[label="content-manager.components.FiltersPickWrapper.PluginHeader.actions.apply"]') + .get( + 'button[label="content-manager.components.FiltersPickWrapper.PluginHeader.actions.apply"]' + ) .click() .wait(animDelay) .get('tbody > tr')