Skip to content

Commit

Permalink
chore: lint/husky
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Feb 4, 2024
1 parent 0df3b19 commit bb32a2f
Show file tree
Hide file tree
Showing 7 changed files with 17,707 additions and 5,028 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
container-query-polyfill.modern.js
cypress
node_modules
acceptance
45 changes: 45 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
extends: ['react-app', 'prettier', 'plugin:jsx-a11y/recommended'],
plugins: ['prettier', 'react-hooks', 'jsx-a11y'],
env: {
es6: true,
browser: true,
node: true,
mocha: true,
jasmine: true,
},
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true,
},
},
rules: {
'import/no-unresolved': 0,
'no-alert': 1,
'no-console': 1,
'no-debugger': 1,
'prettier/prettier': ['error', { trailingComma: 'all', singleQuote: true }],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/react-in-jsx-scope': 'off',
},
globals: {
root: true,
__DEVELOPMENT__: true,
__CLIENT__: true,
__SERVER__: true,
__DISABLE_SSR__: true,
__DEVTOOLS__: true,
__DEBUG__: true,
__SSR__: true,
__SENTRY__: true,
cy: true,
Cypress: true,
jest: true,
socket: true,
webpackIsomorphicTools: true,
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ npm-debug.log*
.DS_Store
*.swp
yarn-error.log
.yarn/

node_modules
build
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHANGELOG.md
README.md
50 changes: 50 additions & 0 deletions .project.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const fs = require('fs');
const path = require('path');

const projectRootPath = fs.realpathSync('./project'); // __dirname
const packageJson = require(path.join(projectRootPath, 'package.json'));

let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');

let configFile;
if (fs.existsSync(`${this.projectRootPath}/tsconfig.json`))
configFile = `${this.projectRootPath}/tsconfig.json`;
else if (fs.existsSync(`${this.projectRootPath}/jsconfig.json`))
configFile = `${this.projectRootPath}/jsconfig.json`;

if (configFile) {
const jsConfig = require(configFile).compilerOptions;
const pathsConfig = jsConfig.paths;
if (pathsConfig['@plone/volto'])
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][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: `${voltoPath}/.eslintrc`,
settings: {
'import/resolver': {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
...addonAliases,
['@package', `${__dirname}/src`],
['@root', `${__dirname}/src`],
['~', `${__dirname}/src`],
],
extensions: ['.js', '.jsx', '.json'],
},
'babel-plugin-root-import': {
rootPathSuffix: 'src',
},
},
},
};
96 changes: 91 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"form"
],
"scripts": {
"i18n": "rm -rf build/messages && NODE_ENV=production i18n -a"
"prepare": "husky install",
"i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
"lint": "./node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx,ts,tsx,json}'"
},
"addons": [
"volto-subblocks"
Expand All @@ -29,8 +31,73 @@
}
},
"prettier": {
"trailingComma": "all",
"singleQuote": true,
"trailingComma": "all"
"overrides": [
{
"files": "*.overrides",
"options": {
"parser": "less"
}
}
]
},
"stylelint": {
"extends": [
"stylelint-config-idiomatic-order"
],
"plugins": [
"stylelint-prettier"
],
"overrides": [
{
"files": [
"**/*.scss"
],
"customSyntax": "postcss-scss"
},
{
"files": [
"**/*.less"
],
"customSyntax": "postcss-less"
},
{
"files": [
"**/*.overrides"
],
"customSyntax": "postcss-less"
}
],
"rules": {
"prettier/prettier": true,
"rule-empty-line-before": [
"always-multi-line",
{
"except": [
"first-nested"
],
"ignore": [
"after-comment"
]
}
]
}
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json}": [
"npx eslint --max-warnings=0 --fix",
"npx prettier --single-quote --write"
],
"src/**/*.{css,less}": [
"npx stylelint --fix"
],
"src/**/*.scss": [
"npx stylelint --fix --customSyntax postcss-scss"
],
"src/**/*.overrides": [
"npx stylelint --fix --syntax less"
]
},
"dependencies": {
"@hcaptcha/react-hcaptcha": "^0.3.6",
Expand All @@ -39,12 +106,31 @@
"volto-subblocks": "^2.0.0"
},
"devDependencies": {
"@babel/plugin-proposal-export-default-from": "7.18.10",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@plone/scripts": "^2.0.0",
"@release-it/conventional-changelog": "^2.0.1",
"husky": "^6.0.0",
"release-it": "^14.11.5"
"@release-it/conventional-changelog": "^5.1.1",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-flowtype": "4.7.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"husky": "8.0.2",
"jest-css-modules": "^2.1.0",
"lint-staged": "13.0.3",
"pofile": "1.0.10",
"prettier": "3.1.0",
"razzle": "4.2.17",
"release-it": "16.1.3",
"stylelint": "15.11.0",
"stylelint-config-idiomatic-order": "9.0.0",
"stylelint-config-prettier": "8.0.1",
"stylelint-prettier": "4.0.2"
},
"peerDependencies": {
"@plone/volto": ">=16.0.0-alpha.38",
Expand Down
Loading

0 comments on commit bb32a2f

Please sign in to comment.