diff --git a/.project.eslintrc.js b/.project.eslintrc.js index 6422d00..765070f 100644 --- a/.project.eslintrc.js +++ b/.project.eslintrc.js @@ -1,17 +1,17 @@ const fs = require('fs'); const path = require('path'); -const projectRootPath = fs.realpathSync('./../../../'); -const projectRootPath = fs.realpathSync('./project'); // __dirname +const projectRootPath = fs.existsSync('./project') + ? fs.realpathSync('./project') + : fs.realpathSync('./../../../'); const packageJson = require(path.join(projectRootPath, 'package.json')); -const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')) - .compilerOptions; +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) => { +Object.keys(pathsConfig).forEach(pkg => { if (pkg === '@plone/volto') { voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`; } @@ -20,11 +20,12 @@ 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) => [ +const addonAliases = Object.keys(reg.packages).map(o => [ o, reg.packages[o].modulePath, ]); + module.exports = { extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`, settings: { @@ -44,3 +45,4 @@ module.exports = { }, }, }; +