Skip to content

Files

Latest commit

6b15b35 · Jan 3, 2025

History

History

eslint-plugin-rules

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 11, 2024
Jul 11, 2024
Dec 20, 2023
Jul 9, 2024
Jan 3, 2025
Jul 13, 2024
Dec 20, 2023
Jan 3, 2025
Dec 20, 2023
Jul 9, 2024

@shiftcode/eslint-plugin-rules

🎯 Target runtime: es2023 (Node >= 20)

⚠️ This module exports code using CommonJS

This module holds some custom eslint plugins written in typescript. See doc for instructions on how to create custom plugins using typescript-eslint.

usage

sample .eslintrc.js file:

module.exports = {
  // ...

  overrides: [
    {
      plugins: ['@shiftcode/rules'],
      files: ['*.ts'],
      rules: {
        '@shiftcode/rules/import-denylist': [ // former TSLint rule: "import-blacklist"
          'error',
          {
            patterns: [
              /aws-cdk-lib\/core/,
              /\.\/(core|models|shared|static)\/.*/, // use app/* instead
              /^app\/core/,    // disallow importing from self
              /^somewhat\/.*/, // import filename must never start with "somewhat"
              /example$/,      // import filename must never end with "example"
              // etc ...
            ]
          }
        ],
      },
    },
  ],

  // ...
}

provided rules

the following custom rules are provided within this module:

deny-parent-index-file-import

import-denylist

This can potentially be replaced by using no-restricted-imports

  • rule accepts a config-object with a patterns regexp array and is the pendant of the former tslint rule "import-blacklist".
  • example configuration: see above