This package has been deprecated

Author message:

The module has been deprecated because the upstream "tslint" project itself got deprecated

tslint-rules-bunch

1.0.0 • Public • Published

tslint-rules-bunch

is a module that contains a set of the tslint rules.

Build Status: Linux / MacOS

Rules

no-import-zones

Forbids specific imports for the specified targets using micromatch patterns matching.

Imagine you have the following directory structure:

└── project
    ├── dist
    ├── src
    │   ├── lib
    │   └── test
    └── tslint.json

You keep the built/compiled/transpiled/release code in the dist directory, source code in src/lib and tests code in src/test. For example you want to make sure that code under src/test directory doesn't import anything from the src/lib as you want tests code does import only from the dist (release code). But as an exclusion you want to allow tests code import stuff from the src/lib/module-1. You can enforce such scenario putting the no-import-zones rule into your tslint.json:

{
  "rulesDirectory": [
    "node_modules/tslint-rules-bunch/rules"
  ],
  "rules": {
    "no-import-zones": [
      true,
      {
        "zones": [
          {
            "patterns": [
              {
                "target": "src/test/**/*",
                "from": [
                  "src/lib",
                  "src/lib/**/*",
                  "!src/lib/module-1"
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}
 

With the basePath value set to src, no-import-zones block would look like this (pattern values don't start from the src anymore):

    "no-import-zones"[
      true,
      {
        "basePath": "src",
        "verbose": true,
        "zones": [
          {
            "patterns": [
              {
                "target": "test/**/*",
                "from": [
                  "lib",
                  "lib/**/*",
                  "!lib/module-1"
                ]
              }
            ]
          }
        ]
      }
    ]

Above code related notes:

  • basePath: defines the base path value that is used for resolving <pattern object>.target and <pattern object>.from values relative to the process.cwd(). It can be set on the top level and also on the specific zone level. The property is optional, by default process.cwd() is used as the base path value.
  • verbose: flag value that toggles detailed failure output, default value is undefined, means false;
  • <pattern object>.target: can be a single value or array of the path pattern to which the forbidding logic should be applied.
  • <pattern object>.from: can be a single value or array of the import patterns that are not allowed to be used by the files matched against the <pattern object>.target pattern.

Readme

Keywords

Package Sidebar

Install

npm i tslint-rules-bunch

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

18.1 kB

Total Files

9

Last publish

Collaborators

  • vladimiry