Skip to content

Commit

Permalink
Only use the new config in core, detecting the VOLTOCONFIG env var.
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Dec 5, 2024
1 parent fd5111d commit 3e473c5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 37 deletions.
60 changes: 23 additions & 37 deletions packages/volto/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,56 +1,42 @@
{
"extends": ["react-app", "prettier", "plugin:jsx-a11y/recommended"],
"extends": [
"react-app",
"prettier",
"plugin:jsx-a11y/recommended",
"./.eslintrc.core.js",
],
"plugins": ["prettier", "react-hooks", "jsx-a11y"],
"root": true,
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true,
"jasmine": true
"jasmine": true,
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"legacyDecorators": true
}
"legacyDecorators": true,
},
},
"rules": {
"import/no-unresolved": 1,
"import/named": "error",
"no-restricted-imports": [
"error",
{
"name": "@plone/volto/components",
"message": "Importing from barrel files is not allowed. The usage of barrel files is discouraged and they will be removed in Plone 7. Please use direct imports of the modules instead."
},
{
"name": "@plone/volto/helpers",
"message": "Importing from barrel files is not allowed. The usage of barrel files is discouraged and they will be removed in Plone 7. Please use direct imports of the modules instead."
},
{
"name": "@plone/volto/actions",
"message": "Importing from barrel files is not allowed. The usage of barrel files is discouraged and they will be removed in Plone 7. Please use direct imports of the modules instead."
},
{
"name": "lodash",
"message": "Importing directly from `lodash` is not allowed. Please use `import <helper> from 'lodash/<helper>'` instead."
}
],
"react/jsx-key": [2, { "checkFragmentShorthand": true }],
"no-alert": 1,
"no-console": 1,
"no-debugger": 1,
"prettier/prettier": [
"error",
{ "trailingComma": "all", "singleQuote": true }
{ "trailingComma": "all", "singleQuote": true },
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/react-in-jsx-scope": "off",
"jsx-a11y/label-has-associated-control": "off"
"jsx-a11y/label-has-associated-control": "off",
},
"settings": {
"import/resolver": {
Expand All @@ -60,18 +46,18 @@
["@plone/volto-slate", "../volto-slate/src"],
["@plone/types", "../types"],
["@package", "./src"],
["@root", "./src"]
["@root", "./src"],
],
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"],
},
"babel-plugin-root-import": {
"rootPathSuffix": "src"
}
"rootPathSuffix": "src",
},
},
"import/core-modules": ["load-volto-addons"],
"react": {
"version": "detect"
}
"version": "detect",
},
},
"overrides": [
{
Expand All @@ -81,14 +67,14 @@
// Re-add it if at some point, we stop relying on it
"extends": ["react-app", "prettier", "plugin:jsx-a11y/recommended"],
"plugins": ["prettier", "react-hooks", "jsx-a11y"],
"parser": "@typescript-eslint/parser"
"parser": "@typescript-eslint/parser",
},
{
"files": ["**/*.stories.js", "**/*.stories.jsx"],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
"import/no-anonymous-default-export": "off",
},
},
],
"globals": {
"root": true,
Expand All @@ -104,6 +90,6 @@
"Cypress": true,
"jest": true,
"socket": true,
"webpackIsomorphicTools": true
}
"webpackIsomorphicTools": true,
},
}
42 changes: 42 additions & 0 deletions packages/volto/.eslintrc.core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** This file is intended to have ESlint configuration only meant to be applied in
* Volto core. Since it relies on the `VOLTOCONFIG` environment variable, it will
* not be applied in CI and command line `make lint` in Volto projects.
* However, it will be applied in IDEs, adding a layer of convenience for developers,
* so they can adapt to use best practices and future deprecations and changes in
* Volto core codebase.
*/
let rules;

if (process.env.VOLTOCONFIG) {
rules = null;
} else {
rules = {
'no-restricted-imports': [
'error',
{
name: '@plone/volto/components',
message:
'Importing from barrel files is not allowed. The usage of barrel files is discouraged and they will be removed in Plone 7. Please use direct imports of the modules instead.',
},
{
name: '@plone/volto/helpers',
message:
'Importing from barrel files is not allowed. The usage of barrel files is discouraged and they will be removed in Plone 7. Please use direct imports of the modules instead.',
},
{
name: '@plone/volto/actions',
message:
'Importing from barrel files is not allowed. The usage of barrel files is discouraged and they will be removed in Plone 7. Please use direct imports of the modules instead.',
},
{
name: 'lodash',
message:
"Importing directly from `lodash` is not allowed. Please use `import <helper> from 'lodash/<helper>'` instead.",
},
],
};
}

module.exports = {
rules,
};

0 comments on commit 3e473c5

Please sign in to comment.