Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ioffice/tslint-config-ioffice

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ioffice/tslint-config-ioffice - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

AMENDMENTS.md

13

CHANGELOG.md

@@ -12,2 +12,12 @@ # Changelog

## [0.2.0] - April 27, 2018
- Added `tsconfig.core.json`. This should provides configuration related to errors in the code.
Other configuration may use it by extending from
`./node_modules/@ioffice/tslint-config-ioffice/tsconfig.core.json`.
### Tslint Rules
- `semicolon`
- `no-interrable-types`
## [0.1.0] - April 26, 2018

@@ -23,3 +33,4 @@ - First release of the guide.

[Unreleased]: https://github.com/ioffice/tslint-config-ioffice/compare/0.1.0...HEAD
[Unreleased]: https://github.com/ioffice/tslint-config-ioffice/compare/0.2.0...HEAD
[0.2.0]: https://github.com/ioffice/tslint-config-ioffice/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/ioffice/tslint-config-ioffice/compare/d35148ee5a67da205b80ea2f8da243e02977b297...0.1.0

2

package.json
{
"name": "@ioffice/tslint-config-ioffice",
"version": "0.1.0",
"version": "0.2.0",
"description": "IOFFICE TypeScript Style Guide",

@@ -5,0 +5,0 @@ "main": "tslint-config-ioffice.json",

<!-- THIS IS AN AUTO-GENERATED FILE - DO NOT MODIFY MANUALLY -->
# iOffice TypeScript Style Guide
Disclaimer: This guide is inspired by the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript#semicolons).
Most sections we see here will be taken straight from their guide and slowly adapted to the typescript language.
## Table of Contents
1. [Functions](#functions)
1. [Types](#types)
1. [Primitives](#types--primitives)
2. [Complex](#types--complex)
2. [Functions](#functions)
1. [Unused Parameters](#functions--unused-parameters)
2. [Arrow Functions](#arrows)
3. [Classes](#classes)
4. [Arrow Functions](#arrows)
1. [Use Them](#arrows--use-them)
3. [Blocks](#blocks)
5. [Blocks](#blocks)
1. [Braces](#blocks--braces)
2. [Cuddled Elses](#blocks--cuddled-elses)
4. [Whitespace](#whitespace)
6. [Whitespace](#whitespace)
1. [Spaces](#whitespace--spaces)
2. [In Braces](#whitespace--in-braces)
5. [Commas](#commas)
7. [Commas](#commas)
1. [Leading Trailing](#commas--leading-trailing)
6. [Modules](#modules)
8. [Semicolons](#semicolons)
1. [Required](#semicolons--required)
9. [Modules](#modules)
1. [Use Them](#modules--use-them)
2. [Single Export](#modules--single-export)
## Types
<a name="types--primitives"></a><a name="1.1"></a>
- [1.1](#types--primitives) **Primitives**: When you access a primitive type you work directly on its value.
- `number`
- `string`
- `boolean`
- `null`
- `undefined`
These types can be inferred by the typescript compiler and should not explicitly typed.
> Why? Explicit types where they can be easily inferred by the compiler make code more verbose.
>
```ts
const foo = 1;
let bar = foo;
bar = 9;
console.log(foo, bar); // => 1, 9
```
```ts
// bad
const foo: number = 1;
// good
let bar: number = foo;
bar = 9;
console.log(foo, bar); // => 1, 9
```
<a name="types--complex"></a><a name="1.2"></a>
- [1.2](#types--complex) **Complex**: When you access a complex type you work on a reference to its value.
- `object`
- `array`
- `function`
```ts
const foo: number[] = [1, 2];
const bar: number[] = foo;
bar[0] = 9;
console.log(foo[0], bar[0]); // => 9, 9
```
**[⬆ back to top](#table-of-contents)**
## Functions
<a name="functions--unused-parameters"></a><a name="1.1"></a>
- [1.1](#functions--unused-parameters) **Unused Parameters**: Remove them. To prevent them make sure to use `noUnusedParameters` in your
<a name="functions--unused-parameters"></a><a name="2.1"></a>
- [2.1](#functions--unused-parameters) **Unused Parameters**: Remove them. To prevent them make sure to use `noUnusedParameters` in your
`tsconfig.json` file.

@@ -51,6 +115,10 @@

## Classes
**[⬆ back to top](#table-of-contents)**
## Arrow Functions
<a name="arrows--use-them"></a><a name="2.1"></a>
- [2.1](#arrows--use-them) **Use Them**: When you must use function expressions (as when passing an anonymous function), use arrow
<a name="arrows--use-them"></a><a name="4.1"></a>
- [4.1](#arrows--use-them) **Use Them**: When you must use function expressions (as when passing an anonymous function), use arrow
function notation.

@@ -89,4 +157,4 @@

<a name="blocks--braces"></a><a name="3.1"></a>
- [3.1](#blocks--braces) **Braces**: Use braces with all multi-line blocks.
<a name="blocks--braces"></a><a name="5.1"></a>
- [5.1](#blocks--braces) **Braces**: Use braces with all multi-line blocks.

@@ -115,4 +183,4 @@ ```ts

<a name="blocks--cuddled-elses"></a><a name="3.2"></a>
- [3.2](#blocks--cuddled-elses) **Cuddled Elses**: If you're using multi-line blocks with `if` and `else`, put `else` on the same line as
<a name="blocks--cuddled-elses"></a><a name="5.2"></a>
- [5.2](#blocks--cuddled-elses) **Cuddled Elses**: If you're using multi-line blocks with `if` and `else`, put `else` on the same line as
your `if` block's closing brace.

@@ -143,4 +211,4 @@

<a name="whitespace--spaces"></a><a name="4.1"></a>
- [4.1](#whitespace--spaces) **Spaces**: Use soft tabs set to 2 spaces.
<a name="whitespace--spaces"></a><a name="6.1"></a>
- [6.1](#whitespace--spaces) **Spaces**: Use soft tabs set to 2 spaces.

@@ -164,4 +232,4 @@ ```ts

<a name="whitespace--in-braces"></a><a name="4.2"></a>
- [4.2](#whitespace--in-braces) **In Braces**: Add spaces inside curly braces.
<a name="whitespace--in-braces"></a><a name="6.2"></a>
- [6.2](#whitespace--in-braces) **In Braces**: Add spaces inside curly braces.

@@ -180,4 +248,4 @@ ```ts

<a name="commas--leading-trailing"></a><a name="5.1"></a>
- [5.1](#commas--leading-trailing) **Leading Trailing**: Leading commas: **Nope**.
<a name="commas--leading-trailing"></a><a name="7.1"></a>
- [7.1](#commas--leading-trailing) **Leading Trailing**: Leading commas: **Nope**.

@@ -218,6 +286,63 @@ ```ts

## Semicolons
<a name="semicolons--required"></a><a name="8.1"></a>
- [8.1](#semicolons--required) **Required**: **Yup**.
> Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules
> called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion)
> to determine whether or not it should regard that line break as the end of a statement, and
> (as the name implies) place a semicolon into your code before the line break if it thinks so.
> ASI contains a few eccentric behaviors, though, and your code will break if JavaScript
> misinterprets your line break. These rules will become more complicated as new features become
> a part of JavaScript. Explicitly terminating your statements and configuring your linter to
> catch missing semicolons will help prevent you from encountering issues.
>
```ts
// bad - raises exception
const luke = {}
const leia = {}
[luke, leia].forEach(jedi => jedi.father = 'vader')
// bad - raises exception
const reaction = "No! That's impossible!"
(async function meanwhileOnTheFalcon() {
// handle `leia`, `lando`, `chewie`, `r2`, `c3p0`
// ...
}())
// bad - returns `undefined` instead of the value on the next line - always happens when `return` is on a line by itself because of ASI!
function foo() {
return
'search your feelings, you know it to be foo'
}
// good
const luke = {};
const leia = {};
[luke, leia].forEach((jedi) => {
jedi.father = 'vader';
});
// good
const reaction = "No! That's impossible!";
(async function meanwhileOnTheFalcon() {
// handle `leia`, `lando`, `chewie`, `r2`, `c3p0`
// ...
}());
// good
function foo() {
return 'search your feelings, you know it to be foo';
}
```
**[⬆ back to top](#table-of-contents)**
## Modules
<a name="modules--use-them"></a><a name="6.1"></a>
- [6.1](#modules--use-them) **Use Them**: Always use modules (`import`/`export`) over a non-standard module system. You can always
<a name="modules--use-them"></a><a name="9.1"></a>
- [9.1](#modules--use-them) **Use Them**: Always use modules (`import`/`export`) over a non-standard module system. You can always
transpile to your preferred module system.

@@ -248,4 +373,4 @@

<a name="modules--single-export"></a><a name="6.2"></a>
- [6.2](#modules--single-export) **Single Export**: Do not use default exports. Use a single named `export` which declares all the classes,
<a name="modules--single-export"></a><a name="9.2"></a>
- [9.2](#modules--single-export) **Single Export**: Do not use default exports. Use a single named `export` which declares all the classes,
functions, objects and interfaces that the module is exporting.

@@ -296,1 +421,31 @@

**[⬆ back to top](#table-of-contents)**
## License
(The MIT License)
Copyright (c) 2018 iOFFICE
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the 'Software'), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Amendments
Following [Airbnb](https://github.com/airbnb/javascript#amendments)'s advice, we also encourage
you to fork this guide and change the rules to fit your team's style guide.
The code provided should make it easy to make adjustments to the examples since
they are linted with the tslint configuration. If you do not agree with part of the configuration
simply change it, test the guide and make the appropiate changes to it.

@@ -10,2 +10,10 @@ {

],
"semicolon": [
true,
"always"
],
"no-inferrable-types": [
true,
"ignore-params"
],
"brace-style": [

@@ -12,0 +20,0 @@ true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc