diff --git a/frontend_addon/{{ cookiecutter.__folder_name }}/.eslintrc.js b/frontend_addon/{{ cookiecutter.__folder_name }}/.eslintrc.js index 9909ae4..f5809aa 100644 --- a/frontend_addon/{{ cookiecutter.__folder_name }}/.eslintrc.js +++ b/frontend_addon/{{ cookiecutter.__folder_name }}/.eslintrc.js @@ -1,5 +1,6 @@ const fs = require('fs'); const projectRootPath = __dirname; +const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry'); let coreLocation; if (fs.existsSync(`${projectRootPath}/core`)) @@ -7,6 +8,16 @@ if (fs.existsSync(`${projectRootPath}/core`)) else if (fs.existsSync(`${projectRootPath}/../../core`)) coreLocation = `${projectRootPath}/../../core`; +const registry = new AddonConfigurationRegistry( + `${coreLocation}/packages/volto`, +); + +// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons +const addonAliases = Object.keys(registry.packages).map((o) => [ + o, + registry.packages[o].modulePath, +]); + module.exports = { extends: `${coreLocation}/packages/volto/.eslintrc`, rules: { @@ -26,6 +37,7 @@ module.exports = { '{{ cookiecutter.__npm_package_name }}', './packages/{{ cookiecutter.frontend_addon_name }}/src', ], + ...addonAliases, ], extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'], }, diff --git a/frontend_addon/{{ cookiecutter.__folder_name }}/Makefile b/frontend_addon/{{ cookiecutter.__folder_name }}/Makefile index eb52e7b..1e2db16 100644 --- a/frontend_addon/{{ cookiecutter.__folder_name }}/Makefile +++ b/frontend_addon/{{ cookiecutter.__folder_name }}/Makefile @@ -35,6 +35,7 @@ help: ## Show this help install: ## Installs the add-on in a development environment pnpm dlx mrs-developer missdev --no-config --fetch-https pnpm i + pnpm build:deps .PHONY: start start: ## Starts Volto, allowing reloading of the add-on during development diff --git a/frontend_addon/{{ cookiecutter.__folder_name }}/package.json b/frontend_addon/{{ cookiecutter.__folder_name }}/package.json index 62823c3..8e8091b 100644 --- a/frontend_addon/{{ cookiecutter.__folder_name }}/package.json +++ b/frontend_addon/{{ cookiecutter.__folder_name }}/package.json @@ -13,14 +13,14 @@ ], "scripts": { "preinstall": "npx only-allow pnpm", - "start": "pnpm build:deps && VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto start", + "start": "VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto start", "start:prod": "pnpm --filter @plone/volto start:prod", - "build": "pnpm build:deps && VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto build", + "build": "VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto build", "build:deps": "pnpm --filter @plone/registry --filter @plone/components build", "i18n": "pnpm --filter {{ cookiecutter.__npm_package_name }} i18n", "test": "RAZZLE_JEST_CONFIG=$(pwd)/jest-addon.config.js pnpm --filter @plone/volto test -- --passWithNoTests", - "lint": "eslint --max-warnings=0 'packages/**/src/**/*.{js,jsx,ts,tsx}'", - "lint:fix": "eslint --fix 'packages/**/src/**/*.{js,jsx,ts,tsx}'", + "lint": "VOLTOCONFIG=$(pwd)/volto.config.js eslint --max-warnings=0 'packages/**/src/**/*.{js,jsx,ts,tsx}'", + "lint:fix": "VOLTOCONFIG=$(pwd)/volto.config.js eslint --fix 'packages/**/src/**/*.{js,jsx,ts,tsx}'", "prettier": "prettier --check 'packages/**/src/**/*.{js,jsx,ts,tsx}'", "prettier:fix": "prettier --write 'packages/**/src/**/*.{js,jsx,ts,tsx}' ", "stylelint": "stylelint 'packages/**/src/**/*.{css,scss,less}' --allow-empty-input",