This rule can be used to disallow files at certain file paths.
Example .eslintrc.js
using the rule's paths
option for matching files based on a regexp pattern:
module.exports = {
rules: {
'square/no-restricted-files': [
'error',
{
paths: ['app/components/[^/]+$'],
message: 'Use a nested scope instead of adding new components to the top-level components folder.',
},
]
}
};
Example .eslintrc.js
using ESLint's built-in overrides feature for matching files based on a glob pattern:
module.exports = {
overrides: [
{
files: ['bad/place/to/add/js/files/**/*.js'],
rules: {
'square/no-restricted-files': ['error', [{ message: 'Do not add JS files here for x reason.' }]],
},
},
],
};
- object[] -- containing the following properties:
- string[] --
paths
-- optional list of regexp file paths to disallow (if you want to use glob patterns, use ESLint's built-in glob pattern overrides feature instead of this) - string --
message
-- optional custom error message to display for these disallowed file paths
- string[] --
There's an autofixer in the rule implementation that can be uncommented as desired.