Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to using TypeScript #84

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
*.iml
.idea
node_modules
npm-debug.log
*.tgz
dist
test/dist
*.js
11 changes: 8 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
app
dist
tslint*
*.iml
.idea
.editorconfig
.gitignore
.npmignore
.travis.yml
package-lock.json
tsconfig.json
tslint.json
test
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ node_js:
- '4'
- '5'
- '6'
- '7'
- '8'
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module.exports = {

// enables type checked rules like 'for-in-array'
// uses tsconfig.json from current working directory
// See the notes on when using this with Webpack watch runs
typeCheck: false,

// automatically fix linting errors
Expand Down Expand Up @@ -115,6 +116,33 @@ module.exports = {
}
```

### typeCheck and Webpack Watch mode
Tslint will use a TypeScript program for typeChecked rules. The TypeScript program will cache file sources
when the program is created and therefore, the program needs to be recreated every watch run to pick
up file changes. This is accomplished using a Webpack plugin.

If you wish to use typeCheck in Webpack watch mode, you'll need to add the `TslintPlugin` to your Webpack config.

```js
var TslintPlugin = require('tslint-loader').TslintPlugin;

module.exports = {
plugins: [
new TslintPlugin()
],
module: {
rules: [
{
test: /\.ts$/,
enforce: 'pre',
loader: 'tslint-loader',
options: { typeCheck: true, /* Loader options go here */ }
}
]
}
}
```

## License

[MIT](http://www.opensource.org/licenses/mit-license.php)
Expand Down
11 changes: 11 additions & 0 deletions formatters/CustomFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Formatters, RuleFailure} from 'tslint';
import {LineAndCharacter} from 'typescript';

export class Formatter extends Formatters.AbstractFormatter {
public format (failures: RuleFailure[]): string {
return failures.map((failure: RuleFailure) => {
const {line, character}: LineAndCharacter = failure.getStartPosition().getLineAndCharacter();
return `[${line + 1}, ${character + 1}]: ${failure.getFailure()}\n`;
}).join('');
}
}
26 changes: 0 additions & 26 deletions formatters/customFormatter.js

This file was deleted.

143 changes: 0 additions & 143 deletions index.js

This file was deleted.

Loading