Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.58 KB

no-restricted-files.md

File metadata and controls

48 lines (37 loc) · 1.58 KB

Disallow files with a path matching a specific regexp (square/no-restricted-files)

This rule can be used to disallow files at certain file paths.

Examples

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.' }]],
      },
    },
  ],
};

Configuration

  • 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

Migration

There's an autofixer in the rule implementation that can be uncommented as desired.