Skip to content

eslint-plugin-rules 6.0.0-pr254.8

Install from the command line:
Learn more about npm packages
$ npm install @shiftcode/eslint-plugin-rules@6.0.0-pr254.8
Install via package.json:
"@shiftcode/eslint-plugin-rules": "6.0.0-pr254.8"

About this version

@shiftcode/eslint-plugin-rules

🎯 Target runtime: es2023 (Node >= 20)

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 eslint.config.msj file:

import eslintScPlugin from '@shiftcode/eslint-plugin-rules'

export default defineConfig(
  // ...
  {
    files: ['*.ts'],
    extends: [eslintScPlugin.configs.recommended],
    rules: {
      '@shiftcode/import-denylist': [
        '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 ...
          ],
        },
      ],
    },
  },

  // ...
)

alternative you can configure the plugin like this:

import eslintScPlugin from '@shiftcode/eslint-plugin-rules'

export default defineConfig({
  files: ['**/*.ts'],
  plugins: {
    '@shiftcode': eslintScPlugin,
  },
  rules: {
    '@shiftcode/prefix-builtin-module-import': 'error',
    // ...
  },
})

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

prefix-builtin-module-import

This rule ensures all node builtin modules are imported with the node: prefix.

✅ Correct

import { writeFile } from 'node:fs/promises'
import crypto from 'node:crypto'

❌ Incorrect

import { writeFile } from 'fs/promises'
import crypto from 'crypto'

Details


Assets

  • eslint-plugin-rules-6.0.0-pr254.8.tgz

Download activity

  • Total downloads 4
  • Last 30 days 4
  • Last week 4
  • Today 0