Some projects have files that aren't meant to be executed in the same environment. For instance, think about a web application with distinct code for the server and the client. In such cases, importing server-only files in client code can lead to issues.
This ESLint rule allows you to specify paths that should be restricted from imports in certain areas of your project. By defining these restricted zones, you can ensure that files intended for a specific environment (e.g., server or client) are not inadvertently imported into the wrong context.
0 - error level, [error | warning] 1 - rules for a folder
Install the ESLint plugin by running:
npm install --save-dev eslint-plugin-jimdo-custom-rules
Add the plugin to your ESLint configuration file, for example, .eslintrc.js
.
e.g. disallow imports containing @apps/wizard
in folder workspace/apps/cms
module.exports = {
plugins: ['jimdo-custom-rules'],
rules: {
'jimdo-custom-rules/disallow-imports-in-folder': ['error', {
folderRules: [
// Define your restricted folders here
folder: 'workspace/apps/cms',
disallowedImports: [
'@apps/wizard',
...
],
],
}],
},
};