0.0.10 • Published 6 years ago

@pinyin/tslint v0.0.10

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

tslint

Build Status

TSLint rules.

Should work for JavaScript projects, too.

Usage

Add this library to project

npm install --save-dev @pinyin/tslint tslint-language-service typescript tslint

Then, edit tsconfig.json to include:

{
  "compilerOptions": {
    "allowJs": true,
    "plugins": [
      {
        "name": "tslint-language-service",
        "mockTypeScriptVersion": true
      }
    ]
  }
}

If you are not using TypeScript, create a tsconfig.json file at the root of your project.

Edit tslint.json to include:

{
  "defaultSeverity": "error",
  "rules": {
    "only-import-from-index": true
  },
  "rulesDirectory": [
    "node_modules/@pinyin/tslint/js"
  ]
}

If you are not using TSLint, create a tslint.json file at the root of your project.

Enable TypeScript in your IDE. You should be able to write JavaScript/TypeScript like before, with some additional checks.

TSLint would start with TypeScript Language Service, so there's no need to enable TSLint in your IDE.

Rules

only-import-from-index

If a directory contains an index.js/index.ts file, files outside of the directory can only import from index.js/index.ts file. No import can "pass through" the index file.

For example, given the following file structure:

src/
    index.ts(content):
        export {a} from './public'
    public.ts:
        import {b} from './private' // ok
        export const a = b
    private.ts:
        export const b = 'b'
out.ts:
    import {a} from './src' // ok
    import {b} from './src/private.ts' // error
    import {a} from './src/public.ts' // error

out.ts can only import from ./src, any other import into src will be reported as Error.

Only imports with relevant path will be checked.

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago