Skip to content

Commit

Permalink
Fixed generator ESlint config. Added tests and docs. (plone#5530)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Piercy <web@stevepiercy.com>
  • Loading branch information
2 people authored and pranayjoshi committed Dec 20, 2023
1 parent 47aad1d commit 425c60b
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 17 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,18 @@ jobs:
run: yarn config set -H enableImmutableInstalls false && yarn
working-directory: ${{env.project-directory}}

- name: Running lint on a project works
run: yarn lint
working-directory: ${{env.project-directory}}

- name: Running prettier on a project works
run: yarn prettier
working-directory: ${{env.project-directory}}

- name: Running stylelint on a project works
run: yarn stylelint
working-directory: ${{env.project-directory}}

- name: Cypress acceptance tests
uses: cypress-io/github-action@v6
env:
Expand Down
28 changes: 28 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ Thus it is safe to run it on top of your project and answer the prompts.

## Upgrading to Volto 18.x.x

### ESlint project configuration update

`@plone/registry` and [other packages on which Volto depends](https://github.com/plone/volto/tree/main/packages) are now stand-alone releases in the monorepo structure released in 18.0.0-alpha.4.

You must update the configuration file {file}`.eslintrc.js` in your projects, according to the following `git diff` patch.

```diff
@@ -18,9 +19,6 @@ if (configFile) {
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

-const AddonConfigurationRegistry = require(
- `${voltoPath}/packages/registry/addon-registry.js`,
-);
const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');

@@ -38,9 +36,7 @@ const defaultConfig = {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
- ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
- ['@plone/registry', '@plone/volto/packages/registry/src'],
- ['@plone/types', '@plone/volto/packages/types'],
+ ['@plone/volto-slate', '@plone/volto-slate/src'],
...addonAliases,
['@package', `${__dirname}/src`],
```

### Upgraded Slate libraries

The support libraries for Slate integration have been upgraded, mainly for bug fixes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"eslint-config-react-app": "7.0.1",
"eslint-plugin-flowtype": "8.0.3",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const projectRootPath = __dirname;
const packageJson = require(path.join(projectRootPath, 'package.json'));
const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');

let voltoPath = './node_modules/@plone/volto';

Expand All @@ -18,9 +19,6 @@ if (configFile) {
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

const AddonConfigurationRegistry = require(
`${voltoPath}/packages/registry/addon-registry.js`,
);
const reg = new AddonConfigurationRegistry(__dirname);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
Expand All @@ -38,9 +36,7 @@ const defaultConfig = {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
['@plone/registry', '@plone/volto/packages/registry/src'],
['@plone/types', '@plone/volto/packages/types'],
['@plone/volto-slate', '@plone/volto-slate/src'],
...addonAliases,
['@package', `${__dirname}/src`],
['@root', `${__dirname}/src`],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"prettier": "./node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,ts,tsx,css,scss}'",
"prettier:fix": "./node_modules/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,ts,tsx,css,scss}'",
"prettier:ci": "./node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,ts,tsx,css,scss}'",
"stylelint": "stylelint 'theme/**/*.{css,scss,less}' 'src/**/*.{css,scss,less}'",
"stylelint:overrides": "stylelint 'theme/**/*.overrides' 'src/**/*.overrides'",
"stylelint": "stylelint 'theme/**/*.{css,scss,less}' 'src/**/*.{css,scss,less}' --allow-empty-input",
"stylelint:overrides": "stylelint 'theme/**/*.overrides' 'src/**/*.overrides' --allow-empty-input",
"stylelint:fix": "yarn stylelint --fix && yarn stylelint:overrides --fix",
"test": "razzle test --passWithNoTests",
"typecheck": "tsc --project tsconfig.json --noEmit",
Expand Down
1 change: 1 addition & 0 deletions packages/generator-volto/news/5530.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the project generator's ESLint configuration, added code quality checks to the CI to ensure a generated project can run these checks, and added documentation for how to reconfigure ESLint in projects. @sneridagh
1 change: 1 addition & 0 deletions packages/volto/news/5530.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the project generator's ESLint configuration, added code quality checks to the CI to ensure a generated project can run these checks, and added documentation for how to reconfigure ESLint in projects. @sneridagh
2 changes: 1 addition & 1 deletion packages/volto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
"eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-babel-plugin-root-import": "1.1.1",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
Expand Down
9 changes: 2 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 425c60b

Please sign in to comment.