├── .editorconfig ├── .eslintrc.yml ├── .gitignore ├── .npmrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── package.json ├── src ├── custom-linter.ts ├── index.ts └── typescript-service.ts ├── test ├── index.spec.ts ├── test-project │ ├── file-spec.ts │ ├── file.ts │ ├── source.ts │ ├── tsconfig-files.json │ ├── tsconfig.json │ └── tslint.json └── test-tslint-rules-directory │ └── alwaysFailRule.js └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [*.json] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | root: true 2 | parser: 'typescript-eslint-parser' 3 | parserOptions: 4 | sourceType: 'module' 5 | rules: 6 | semi: ['error', 'always'] 7 | quotes: ['error', 'single'] 8 | comma-dangle: ['error', { 9 | arrays: 'always-multiline', 10 | objects: 'always-multiline', 11 | imports: 'always-multiline', 12 | exports: 'always-multiline', 13 | functions: 'always-multiline' 14 | }] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | *.log 3 | npm-debug.log* 4 | pids 5 | *.pid 6 | *.seed 7 | lib-cov 8 | coverage 9 | .nyc_output 10 | .grunt 11 | .lock-wscript 12 | build/Release 13 | node_modules 14 | jspm_packages 15 | .npm 16 | .node_repl_history 17 | .vscode 18 | /dist/ 19 | ~* -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock = false 2 | # save-exact = true 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | notifications: 3 | email: false 4 | language: node_js 5 | cache: 6 | directories: 7 | - node_modules 8 | node_js: 9 | - '8' 10 | install: 11 | - npm install 12 | script: 13 | - npm test 14 | deploy: 15 | provider: script 16 | skip_cleanup: true 17 | script: 18 | npx semantic-release 19 | on: 20 | branch: master 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [3.1.0](https://github.com/JamesHenry/eslint-plugin-tslint/compare/v3.0.0...v3.1.0) (2018-10-19) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * Tiny lint note elimination ([a731838](https://github.com/JamesHenry/eslint-plugin-tslint/commit/a731838)) 7 | 8 | 9 | ### Features 10 | 11 | * Support for tslint property ([18a4afb](https://github.com/JamesHenry/eslint-plugin-tslint/commit/18a4afb)), closes [#40](https://github.com/JamesHenry/eslint-plugin-tslint/issues/40) 12 | 13 | # [3.0.0](https://github.com/JamesHenry/eslint-plugin-tslint/compare/v2.1.0...v3.0.0) (2018-09-09) 14 | 15 | 16 | ### Bug Fixes 17 | 18 | * Fixed bug when file not defined in tsconfig ([20b498b](https://github.com/JamesHenry/eslint-plugin-tslint/commit/20b498b)) 19 | * Pass sourceText parameter to service getSource ([dd4c2f8](https://github.com/JamesHenry/eslint-plugin-tslint/commit/dd4c2f8)) 20 | * Update program when sourceFile was updated ([0fe933c](https://github.com/JamesHenry/eslint-plugin-tslint/commit/0fe933c)) 21 | * Updated typescript-service dependency ([2f4f434](https://github.com/JamesHenry/eslint-plugin-tslint/commit/2f4f434)) 22 | 23 | 24 | ### Features 25 | 26 | * **core:** Added support rules requires type information ([6bc1deb](https://github.com/JamesHenry/eslint-plugin-tslint/commit/6bc1deb)), closes [#32](https://github.com/JamesHenry/eslint-plugin-tslint/issues/32) [#34](https://github.com/JamesHenry/eslint-plugin-tslint/issues/34) 27 | * Post merge adapdation from tslint2 repository ([477c656](https://github.com/JamesHenry/eslint-plugin-tslint/commit/477c656)), closes [#32](https://github.com/JamesHenry/eslint-plugin-tslint/issues/32) [#34](https://github.com/JamesHenry/eslint-plugin-tslint/issues/34) 28 | 29 | 30 | ### BREAKING CHANGES 31 | 32 | * New dependency 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 James Henry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This project has been moved to the TypeScript ESLint organization -> https://typescript-eslint.io 2 | 3 | 4 | --- 5 | 6 | # ESLint Plugin TSLint 7 | [![Travis](https://img.shields.io/travis/JamesHenry/eslint-plugin-tslint.svg?style=flat-square)](https://travis-ci.org/JamesHenry/eslint-plugin-tslint) 8 | [![GitHub license](https://img.shields.io/npm/l/eslint-plugin-tslint.svg?style=flat-square)](https://github.com/JamesHenry/eslint-plugin-tslint/blob/master/LICENSE) 9 | [![NPM Version](https://img.shields.io/npm/v/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-tslint) 10 | [![NPM Downloads](https://img.shields.io/npm/dt/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-tslint) 11 | [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) 12 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) 13 | [![greenkeeper.io](https://badges.greenkeeper.io/JamesHenry/mongoose-schema-to-typescript-interface.svg?style=flat-square)](https://greenkeeper.io) 14 | 15 | ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint. 16 | 17 | ## INSTALL 18 | ``` 19 | npm i -D eslint-plugin-tslint 20 | ``` 21 | 22 | ## USAGE 23 | Configure in your eslint config file: 24 | ``` 25 | "plugins": [ 26 | "tslint" 27 | ], 28 | "rules": { 29 | "tslint/config": ["warn", { 30 | lintFile: '/* path to tslint.json of your project */', 31 | rules: { /* tslint rules (will be used if `lintFile` is not specified) */ }, 32 | rulesDirectory: [ /* array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified) */ ], 33 | configFile: '/* path to tsconfig.json of your project */', 34 | compilerOptions: { /* ability to override TypeScript compilers options defined in tsconfig.json */ } 35 | }], 36 | } 37 | ``` 38 | 39 | ## RULES 40 | Plugin contains only single rule `tslint/config`. 41 | 42 | ## EXAMPLES 43 | * [unlight/node-package-starter/.eslintrc.js](https://github.com/unlight/node-package-starter/blob/master/.eslintrc.js) 44 | 45 | ### TSLint Plugins 46 | * https://github.com/Glavin001/tslint-clean-code 47 | * https://github.com/Microsoft/tslint-microsoft-contrib 48 | * https://github.com/SonarSource/SonarTS 49 | * https://github.com/ajafff/tslint-consistent-codestyle 50 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-plugin-tslint", 3 | "version": "3.1.0", 4 | "main": "dist/index.js", 5 | "typings": "src/index.ts", 6 | "author": "James Henry ", 7 | "contributors": [ 8 | "Roman Vasilev (https://github.com/unlight)" 9 | ], 10 | "description": "TSLint wrapper plugin for ESLint", 11 | "keywords": [ 12 | "eslint", 13 | "eslintplugin", 14 | "eslint-plugin", 15 | "tslint" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/JamesHenry/eslint-plugin-tslint.git" 20 | }, 21 | "license": "MIT", 22 | "scripts": { 23 | "test": "npm run eslint && npm run tscheck && npm run test:cov", 24 | "tscheck": "echo tscheck... && tsc --noEmit", 25 | "test:r": "mocha -r ts-node/register/transpile-only --timeout 8s test/*.spec.ts", 26 | "test:w": "mocha -r ts-node/register/transpile-only --watch-extensions ts --watch --timeout 8s test/**/*.spec.ts", 27 | "test:cov": "nyc mocha --timeout 8s test/**/*.spec.ts", 28 | "test:d": "node --inspect-brk -r ts-node/register/transpile-only node_modules/mocha/bin/_mocha --no-timeouts --watch-extensions ts --watch test/**/*.spec.ts", 29 | "eslint": "eslint src --ext ts", 30 | "prepublishOnly": "npm run build && sed -i -e 's/devDependencies/_devDependencies/g' package.json", 31 | "build": "tsc", 32 | "prebuild": "npm run clean", 33 | "clean": "rm -rf dist/", 34 | "cz": "git-cz" 35 | }, 36 | "dependencies": { 37 | "lodash.memoize": "^4.1.2", 38 | "typescript-service": "^2.0.3" 39 | }, 40 | "peerDependencies": { 41 | "tslint": "^5.0.0" 42 | }, 43 | "devDependencies": { 44 | "@semantic-release/changelog": "^3.0.1", 45 | "@semantic-release/git": "^7.0.5", 46 | "@types/eslint": "^4.16.3", 47 | "@types/lodash.memoize": "^4.1.4", 48 | "@types/mocha": "^5.2.5", 49 | "@types/node": "^10.12.0", 50 | "cz-conventional-changelog": "^2.1.0", 51 | "eslint": "^5.7.0", 52 | "mocha": "^5.2.0", 53 | "nyc": "^13.1.0", 54 | "semantic-release": "^15.10.3", 55 | "ts-node": "^7.0.1", 56 | "tslint": "^5.11.0", 57 | "typescript": "^3.1.3", 58 | "typescript-eslint-parser": "^20.0.0" 59 | }, 60 | "nyc": { 61 | "include": [ 62 | "src/**/*.ts", 63 | "src/**/*.tsx" 64 | ], 65 | "exclude": [ 66 | "**/*.d.ts", 67 | "**/*.spec.ts" 68 | ], 69 | "extension": [ 70 | ".ts", 71 | ".tsx" 72 | ], 73 | "require": [ 74 | "ts-node/register/transpile-only" 75 | ], 76 | "reporter": [ 77 | "text" 78 | ], 79 | "sourceMap": true, 80 | "instrument": true 81 | }, 82 | "release": { 83 | "verifyConditions": [ 84 | "@semantic-release/changelog", 85 | "@semantic-release/github", 86 | "@semantic-release/npm", 87 | "@semantic-release/git" 88 | ], 89 | "prepare": [ 90 | "@semantic-release/changelog", 91 | "@semantic-release/npm", 92 | "@semantic-release/git" 93 | ], 94 | "publish": [ 95 | "@semantic-release/npm", 96 | "@semantic-release/github" 97 | ], 98 | "success": [ 99 | "@semantic-release/github" 100 | ], 101 | "fail": [ 102 | "@semantic-release/github" 103 | ] 104 | }, 105 | "config": { 106 | "commitizen": { 107 | "path": "cz-conventional-changelog" 108 | } 109 | }, 110 | "bugs": { 111 | "url": "https://github.com/JamesHenry/eslint-plugin-tslint/issues" 112 | }, 113 | "homepage": "https://github.com/JamesHenry/eslint-plugin-tslint#readme", 114 | "directories": { 115 | "test": "test" 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/custom-linter.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { ILinterOptions, LintResult } from 'tslint'; 3 | import { typescriptService } from './typescript-service'; 4 | const { Linter: TSLintLinter } = require('tslint'); 5 | 6 | export class CustomLinter extends TSLintLinter { 7 | 8 | constructor(options: ILinterOptions, program?: ts.Program | undefined) { 9 | super(options, program); 10 | } 11 | 12 | getResult(): LintResult { 13 | return super.getResult(); 14 | } 15 | 16 | getSourceFile(fileName: string, source: string) { 17 | if (this.program === undefined) { 18 | return super.getSourceFile(fileName, source); 19 | } 20 | const service = typescriptService(); 21 | const result = service.getSourceFile(fileName, source); 22 | this.program = service.getProgram(); 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview TSLint wrapper plugin for ESLint 3 | * @author James Henry 4 | */ 5 | 6 | //------------------------------------------------------------------------------ 7 | // Requirements 8 | //------------------------------------------------------------------------------ 9 | 10 | import { RuleSeverity, Configuration } from 'tslint'; 11 | import * as ts from 'typescript'; 12 | import { Rule } from 'eslint'; 13 | import { typescriptService } from './typescript-service'; 14 | import { CustomLinter } from './custom-linter'; 15 | import memoize = require('lodash.memoize'); 16 | 17 | //------------------------------------------------------------------------------ 18 | // Plugin Definition 19 | //------------------------------------------------------------------------------ 20 | 21 | type RawRuleConfig = 22 | | null 23 | | undefined 24 | | boolean 25 | | any[] 26 | | { 27 | severity?: RuleSeverity | 'warn' | 'none' | 'default'; 28 | options?: any; 29 | }; 30 | 31 | interface RawRulesConfig { 32 | [key: string]: RawRuleConfig; 33 | } 34 | 35 | 36 | /** 37 | * Construct a configFile for TSLint 38 | */ 39 | const tslintConfig = memoize((lintFile: string, tslintRules: RawRulesConfig, tslintRulesDirectory: string[]) => { 40 | if (lintFile != null) { 41 | return Configuration.loadConfigurationFromPath(lintFile); 42 | } 43 | return Configuration.parseConfigFile({ 44 | rules: tslintRules || {}, 45 | rulesDirectory: tslintRulesDirectory || [], 46 | }); 47 | }, (lintFile: string | undefined, tslintRules = {}, tslintRulesDirectory = []) => `${lintFile}_${Object.keys(tslintRules).join(',')}_${tslintRulesDirectory.length}`); 48 | 49 | export const rules = { 50 | /** 51 | * Expose a single rule called "config", which will be accessed in the user's eslint config files 52 | * via "tslint/config" 53 | */ 54 | config: { 55 | meta: { 56 | docs: { 57 | description: 'Wraps a TSLint configuration and lints the whole source using TSLint', 58 | category: 'TSLint', 59 | }, 60 | schema: [ 61 | { 62 | type: 'object', 63 | properties: { 64 | rules: { 65 | type: 'object', 66 | /** 67 | * No fixed schema properties for rules, as this would be a permanently moving target 68 | */ 69 | additionalProperties: true, 70 | }, 71 | rulesDirectory: { 72 | type: 'array', 73 | items: { 74 | type: 'string', 75 | }, 76 | }, 77 | configFile: { 78 | type: 'string', 79 | }, 80 | lintFile: { 81 | type: 'string', 82 | }, 83 | compilerOptions: { 84 | type: 'object', 85 | additionalProperties: true, 86 | }, 87 | }, 88 | additionalProperties: false, 89 | }, 90 | ], 91 | }, 92 | create: function(context: Rule.RuleContext) { 93 | const fileName = context.getFilename(); 94 | const sourceCode = context.getSourceCode().text; 95 | 96 | /** 97 | * The TSLint rules configuration passed in by the user 98 | */ 99 | const { 100 | rules: tslintRules, 101 | rulesDirectory: tslintRulesDirectory, 102 | configFile, 103 | lintFile, 104 | compilerOptions, 105 | } = context.options[0]; 106 | 107 | let program: ts.Program | undefined = undefined; 108 | 109 | if (fileName !== '' && configFile) { 110 | const service = typescriptService({ configFile, compilerOptions }); 111 | program = service.getProgram(); 112 | } 113 | 114 | /** 115 | * Create an instance of TSLint 116 | * Lint the source code using the configured TSLint instance, and the rules which have been 117 | * passed via the ESLint rule options for this rule (using "tslint/config") 118 | */ 119 | const tslintOptions = { 120 | formatter: 'json', 121 | fix: false, 122 | }; 123 | const tslint = new CustomLinter(tslintOptions, program); 124 | const configuration = tslintConfig(lintFile, tslintRules, tslintRulesDirectory); 125 | tslint.lint(fileName, sourceCode, configuration); 126 | 127 | const result = tslint.getResult(); 128 | 129 | /** 130 | * Format the TSLint results for ESLint 131 | */ 132 | if (result.failures && result.failures.length) { 133 | result.failures.forEach(failure => { 134 | const start = failure.getStartPosition().getLineAndCharacter(); 135 | const end = failure.getEndPosition().getLineAndCharacter(); 136 | context.report({ 137 | message: `${failure.getFailure()} (tslint:${failure.getRuleName()})`, 138 | loc: { 139 | start: { 140 | line: start.line + 1, 141 | column: start.character, 142 | }, 143 | end: { 144 | line: end.line + 1, 145 | column: end.character, 146 | }, 147 | }, 148 | }); 149 | }); 150 | } 151 | 152 | /** 153 | * Return an empty object for the ESLint rule 154 | */ 155 | return {}; 156 | }, 157 | }, 158 | }; 159 | -------------------------------------------------------------------------------- /src/typescript-service.ts: -------------------------------------------------------------------------------- 1 | import { createService } from 'typescript-service'; 2 | import * as ts from 'typescript'; 3 | 4 | let service: ReturnType; 5 | 6 | type createServiceOptions = { 7 | configFile: string; 8 | compilerOptions?: ts.CompilerOptions; 9 | }; 10 | 11 | export function typescriptService(options?: createServiceOptions) { 12 | if (service === undefined) { 13 | if (options === undefined) { 14 | throw new Error('Service is not yet created'); 15 | } 16 | service = createService(options); 17 | } 18 | return service; 19 | } 20 | -------------------------------------------------------------------------------- /test/index.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview TSLint wrapper plugin for ESLint 3 | * @author James Henry 4 | */ 5 | 6 | import { rules } from '../src/index'; 7 | import { RuleTester, Linter } from 'eslint'; 8 | import { readFileSync } from 'fs'; 9 | 10 | //------------------------------------------------------------------------------ 11 | // Tests 12 | //------------------------------------------------------------------------------ 13 | 14 | const ruleTester = new RuleTester(); 15 | 16 | const parserOptions: Linter.ParserOptions = { 17 | ecmaVersion: 6, 18 | sourceType: 'module', 19 | ecmaFeatures: {}, 20 | }; 21 | 22 | /** 23 | * Inline rules should be supported 24 | */ 25 | const tslintRulesConfig = { 26 | rules: { 27 | semicolon: [true, 'always'], 28 | }, 29 | }; 30 | 31 | /** 32 | * Custom rules directories should be supported 33 | */ 34 | const tslintRulesDirectoryConfig = { 35 | rulesDirectory: ['./test/test-tslint-rules-directory'], 36 | rules: { 37 | 'always-fail': { 38 | severity: 'error', 39 | }, 40 | }, 41 | }; 42 | 43 | ruleTester.run('tslint/config', rules.config, { 44 | valid: [ 45 | { 46 | code: 'var foo = true;', 47 | parser: 'typescript-eslint-parser', 48 | parserOptions, 49 | options: [tslintRulesConfig], 50 | }, 51 | { 52 | filename: './test/test-project/file-spec.ts', 53 | code: readFileSync('./test/test-project/file-spec.ts', 'utf8').replace(/\n/g, ' '), 54 | parser: 'typescript-eslint-parser', 55 | parserOptions, 56 | options: [ 57 | { 58 | ...tslintRulesConfig, 59 | configFile: `${__dirname}/test-project/tsconfig-files.json`, 60 | }, 61 | ], 62 | }, 63 | { 64 | code: 'throw "should be ok because rule is not loaded";', 65 | parser: 'typescript-eslint-parser', 66 | parserOptions, 67 | options: [tslintRulesConfig], 68 | }, 69 | ], 70 | 71 | invalid: [ 72 | { 73 | options: [{ lintFile: './test/test-project/tslint.json' }], 74 | parser: 'typescript-eslint-parser', 75 | parserOptions, 76 | code: 'throw "err" // no-string-throw', 77 | errors: [ 78 | { message: 'Throwing plain strings (not instances of Error) gives no stack traces (tslint:no-string-throw)' }, 79 | ], 80 | }, 81 | { 82 | code: 'var foo = true // semicolon', 83 | parser: 'typescript-eslint-parser', 84 | parserOptions, 85 | options: [tslintRulesConfig], 86 | output: 'var foo = true // semicolon', 87 | errors: [ 88 | { 89 | message: 'Missing semicolon (tslint:semicolon)', 90 | line: 1, 91 | column: 15, 92 | }, 93 | ], 94 | }, 95 | { 96 | code: 'var foo = true // fail', 97 | parser: 'typescript-eslint-parser', 98 | parserOptions, 99 | options: [tslintRulesDirectoryConfig], 100 | output: 'var foo = true // fail', 101 | errors: [ 102 | { 103 | message: 'failure (tslint:always-fail)', 104 | line: 1, 105 | column: 1, 106 | }, 107 | ], 108 | }, 109 | { 110 | filename: './test/test-project/source.ts', 111 | code: readFileSync('./test/test-project/source.ts', 'utf8').replace(/\n/g, ' '), 112 | parser: 'typescript-eslint-parser', 113 | parserOptions, 114 | options: [ 115 | { 116 | rulesDirectory: ['node_modules/tslint/lib/rules'], 117 | rules: { 'restrict-plus-operands': true }, 118 | configFile: `${__dirname}/test-project/tsconfig.json`, 119 | }, 120 | ], 121 | errors: [ 122 | { 123 | message: 124 | 'Operands of \'+\' operation must either be both strings or both numbers, consider using template literals (tslint:restrict-plus-operands)', 125 | }, 126 | ], 127 | }, 128 | ], 129 | }); 130 | -------------------------------------------------------------------------------- /test/test-project/file-spec.ts: -------------------------------------------------------------------------------- 1 | import { x } from './file'; 2 | console.assert(x); 3 | -------------------------------------------------------------------------------- /test/test-project/file.ts: -------------------------------------------------------------------------------- 1 | import * as number from './number'; 2 | export const x = 1; 3 | console.log(number); 4 | -------------------------------------------------------------------------------- /test/test-project/source.ts: -------------------------------------------------------------------------------- 1 | const a: string = 1; 2 | const sum = 1 + '2'; 3 | -------------------------------------------------------------------------------- /test/test-project/tsconfig-files.json: -------------------------------------------------------------------------------- 1 | { 2 | "lib": ["dom"], 3 | "files": [ 4 | "file.ts" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /test/test-project/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "strict": true, 6 | "noUnusedLocals": true, 7 | "noImplicitAny": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/test-project/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-string-throw": true, 4 | "no-var-keyword": true, 5 | "prefer-const": true, 6 | "radix": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/test-tslint-rules-directory/alwaysFailRule.js: -------------------------------------------------------------------------------- 1 | const Lint = require('tslint'); 2 | 3 | class Rule extends Lint.Rules.AbstractRule { 4 | 5 | apply(sourceFile) { 6 | return this.applyWithWalker( 7 | new AlwaysFailWalker(sourceFile, this.getOptions()), 8 | ); 9 | } 10 | } 11 | 12 | 13 | class AlwaysFailWalker extends Lint.RuleWalker { 14 | 15 | visitSourceFile(node) { 16 | this.addFailure( 17 | this.createFailure(node.getStart(), node.getWidth(), 'failure'), 18 | ); 19 | } 20 | } 21 | 22 | exports.Rule = Rule; 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "removeComments": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "sourceMap": true, 10 | "pretty": true, 11 | "allowUnreachableCode": false, 12 | "noFallthroughCasesInSwitch": false, 13 | "noImplicitReturns": true, 14 | "noImplicitAny": true, 15 | "strictNullChecks": true, 16 | "noUnusedParameters": true, 17 | "noUnusedLocals": true, 18 | "skipLibCheck": true, 19 | "skipDefaultLibCheck": true, 20 | "outDir": "./dist", 21 | "types": [ 22 | "node" 23 | ], 24 | "lib": [ 25 | "es2015" 26 | ] 27 | }, 28 | "include": [ 29 | "src/**/*.ts" 30 | ], 31 | "exclude": [ 32 | "node_modules" 33 | ], 34 | "compileOnSave": false, 35 | "buildOnSave": false, 36 | "atom": { 37 | "rewriteTsconfig": false 38 | } 39 | } --------------------------------------------------------------------------------