From f4b2e259812da2a127e198954eb7c621e7848e0f Mon Sep 17 00:00:00 2001 From: andreiggr Date: Thu, 15 Dec 2022 13:04:04 +0200 Subject: [PATCH] add missing eslintrc.js --- .eslintrc.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 - .project.eslintrc.js | 1 - Jenkinsfile | 3 --- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..8fc4f4e --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,44 @@ +const fs = require('fs'); +const path = require('path'); + +const projectRootPath = fs.realpathSync('./project'); // __dirname +const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')) + .compilerOptions; + +const pathsConfig = jsConfig.paths; + +let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto'); + +Object.keys(pathsConfig).forEach((pkg) => { + if (pkg === '@plone/volto') { + voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`; + } +}); +const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`); +const reg = new AddonConfigurationRegistry(projectRootPath); + +// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons +const addonAliases = Object.keys(reg.packages).map((o) => [ + o, + reg.packages[o].modulePath, +]); + +module.exports = { + extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`, + settings: { + 'import/resolver': { + alias: { + map: [ + ['@plone/volto', '@plone/volto/src'], + ...addonAliases, + ['@package', `${__dirname}/src`], + ['~', `${__dirname}/src`], + ], + extensions: ['.js', '.jsx', '.json'], + }, + 'babel-plugin-root-import': { + rootPathSuffix: 'src', + }, + }, + }, +}; diff --git a/.gitignore b/.gitignore index 12abb36..f5aae09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .vscode/ .history -.eslintrc.js nyc_output project coverage diff --git a/.project.eslintrc.js b/.project.eslintrc.js index cfefd89..ac3c8f3 100644 --- a/.project.eslintrc.js +++ b/.project.eslintrc.js @@ -2,7 +2,6 @@ const fs = require('fs'); const path = require('path'); const projectRootPath = fs.realpathSync('./project'); // __dirname -const packageJson = require(path.join(projectRootPath, 'package.json')); const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions; const pathsConfig = jsConfig.paths; diff --git a/Jenkinsfile b/Jenkinsfile index 9289309..202ac54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,21 +41,18 @@ pipeline { "ES lint": { node(label: 'docker') { - sh '''docker pull plone/volto-addon-ci:alpha''' sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha eslint''' } }, "Style lint": { node(label: 'docker') { - sh '''docker pull plone/volto-addon-ci:alpha''' sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha stylelint''' } }, "Prettier": { node(label: 'docker') { - sh '''docker pull plone/volto-addon-ci:alpha''' sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci:alpha prettier''' } }