@ioffice/tslint-config-ioffice
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -12,2 +12,10 @@ # Changelog | ||
## [0.6.0] - November 14, 2018 | ||
*Sections* | ||
- Type Assertion: forces use of `as Type` syntax. | ||
- Consecutive Blank Lines: Lets avoid them. | ||
- Import Order: Lets start alphabetizing and grouping our imports. | ||
- Multiline Imports: No way to enforce this yet, but an example has been included. | ||
## [0.5.0] - June 26, 2018 | ||
@@ -52,3 +60,4 @@ *Sections* | ||
[Unreleased]: https://github.com/ioffice/tslint-config-ioffice/compare/0.5.0...HEAD | ||
[Unreleased]: https://github.com/ioffice/tslint-config-ioffice/compare/0.6.0...HEAD | ||
[0.6.0]: https://github.com/ioffice/tslint-config-ioffice/compare/0.5.0...0.6.0 | ||
[0.5.0]: https://github.com/ioffice/tslint-config-ioffice/compare/0.4.1...0.5.0 | ||
@@ -55,0 +64,0 @@ [0.4.1]: https://github.com/ioffice/tslint-config-ioffice/compare/0.4.0...0.4.1 |
{ | ||
"name": "@ioffice/tslint-config-ioffice", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "IOFFICE TypeScript Style Guide", | ||
@@ -44,3 +44,3 @@ "main": "tslint-config-ioffice.json", | ||
"sinon": "6.0.1", | ||
"tslint": "5.10.0", | ||
"tslint": "5.11.0", | ||
"tslint-eslint-rules": "5.3.1", | ||
@@ -47,0 +47,0 @@ "typedoc": "0.11.1", |
@@ -15,2 +15,3 @@ <!-- THIS IS AN AUTO-GENERATED FILE - DO NOT MODIFY MANUALLY --> | ||
2. [Complex](#types--complex) | ||
3. [Type Assertion](#types--type-assertion) | ||
2. [References](#references) | ||
@@ -33,2 +34,3 @@ 1. [Prefer Const](#references--prefer-const) | ||
3. [In Braces](#whitespace--in-braces) | ||
4. [Consecutive Blank Lines](#whitespace--consecutive-blank-lines) | ||
8. [Commas](#commas) | ||
@@ -42,2 +44,4 @@ 1. [Leading Commas](#commas--leading-commas) | ||
2. [Single Export](#modules--single-export) | ||
3. [Import Order](#modules--import-order) | ||
4. [Multiline Imports](#modules--multiline-imports) | ||
@@ -98,2 +102,27 @@ ## Types | ||
<a name="types--type-assertion"></a><a name="1.3"></a> | ||
- [1.3](#types--type-assertion) **Type Assertion**: Avoid using the angle bracket type assertion. | ||
> Although both formats have the same effect our goal is to have a consistent type | ||
> assertion style across our codebase. Using the `as Type` syntax can also avoid confusion | ||
> with generic methods and classes that use angle brackets. | ||
> | ||
```ts | ||
// bad | ||
processProperty(<Person>user.property); | ||
// good | ||
processProperty((user as Person).property); | ||
``` | ||
```ts | ||
// bad | ||
someGenericMethod<Person>(<Person>user); | ||
// good | ||
someGenericMethod<Person>(user as Person); | ||
``` | ||
**[⬆ back to top](#table-of-contents)** | ||
@@ -464,2 +493,19 @@ | ||
<a name="whitespace--consecutive-blank-lines"></a><a name="7.4"></a> | ||
- [7.4](#whitespace--consecutive-blank-lines) **Consecutive Blank Lines**: Avoid multiple empty lines and only allow one line at the end of the file. | ||
```ts | ||
// bad | ||
const x = 1; | ||
const y = 2; | ||
// good | ||
const x = 1; | ||
const y = 2; | ||
``` | ||
**[⬆ back to top](#table-of-contents)** | ||
@@ -735,2 +781,55 @@ | ||
<a name="modules--import-order"></a><a name="10.3"></a> | ||
- [10.3](#modules--import-order) **Import Order**: Import statements should be alphabetized and grouped. | ||
> Why? It enforces a consistent ordering. | ||
> | ||
```ts | ||
// bad | ||
import { B, A } from 'xyz'; | ||
// good | ||
import { A, B } from 'xyz'; | ||
``` | ||
```ts | ||
// bad | ||
import { a } from './local/path'; | ||
import { B, A, D, C } from 'xyz'; | ||
import { b } from '../parent/directory'; | ||
``` | ||
```ts | ||
// good | ||
import { A, B, C, D } from 'xyz'; | ||
import { b } from '../parent/directory'; | ||
import { a } from './local/path'; | ||
``` | ||
<a name="modules--multiline-imports"></a><a name="10.4"></a> | ||
- [10.4](#modules--multiline-imports) **Multiline Imports**: Multiline imports should be indented just like multiline array and object literals. | ||
> Why? The curly braces follow the same indentation rules as every other curly brace block in the | ||
> style guide, as do the trailing commas. | ||
> | ||
```ts | ||
// bad | ||
import {longNameA, longNameB, longNameC, longNameD, longNameE} from 'path'; | ||
// good | ||
import { | ||
longNameA, | ||
longNameB, | ||
longNameC, | ||
longNameD, | ||
longNameE, | ||
} from 'path'; | ||
``` | ||
**[⬆ back to top](#table-of-contents)** | ||
@@ -737,0 +836,0 @@ |
@@ -0,3 +1,3 @@ | ||
import * as Lint from 'tslint'; | ||
import * as ts from 'typescript'; | ||
import * as Lint from 'tslint'; | ||
declare class Rule extends Lint.Rules.AbstractRule { | ||
@@ -4,0 +4,0 @@ static metadata: Lint.IRuleMetadata; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var Lint = require("tslint"); | ||
var ts = require("typescript"); | ||
var Lint = require("tslint"); | ||
var RULE_NAME = 'io-export-style'; | ||
@@ -7,0 +7,0 @@ var MSG = { |
@@ -10,2 +10,9 @@ { | ||
], | ||
"no-angle-bracket-type-assertion": true, | ||
"ordered-imports": [ | ||
true, | ||
{ | ||
"grouped-imports": true | ||
} | ||
], | ||
"no-multi-spaces": [ | ||
@@ -67,2 +74,3 @@ true, | ||
], | ||
"no-consecutive-blank-lines": true, | ||
"ter-indent": [ | ||
@@ -69,0 +77,0 @@ true, |
34704
263
863