Skip to content

Commit

Permalink
Improve linting, and polish start/build/install scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Jun 7, 2024
1 parent 07810b0 commit 5e8b7f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
12 changes: 12 additions & 0 deletions frontend_addon/{{ cookiecutter.__folder_name }}/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
const fs = require('fs');
const projectRootPath = __dirname;
const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');

let coreLocation;
if (fs.existsSync(`${projectRootPath}/core`))
coreLocation = `${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: {
Expand All @@ -26,6 +37,7 @@ module.exports = {
'{{ cookiecutter.__npm_package_name }}',
'./packages/{{ cookiecutter.frontend_addon_name }}/src',
],
...addonAliases,
],
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
},
Expand Down
1 change: 1 addition & 0 deletions frontend_addon/{{ cookiecutter.__folder_name }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions frontend_addon/{{ cookiecutter.__folder_name }}/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5e8b7f8

Please sign in to comment.