Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Use prettier to format source files #623

Merged
merged 39 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d5efb2d
Add prettier, prettierrc and prettierignore
mesaugat Nov 1, 2018
2b5de33
Add tslint-config-prettier to avoid tslint and prettier conflicts
mesaugat Nov 1, 2018
baafedf
First prettier run
mesaugat Nov 1, 2018
4993b0f
Prettify json files
mesaugat Nov 1, 2018
89fa9ef
Ignore package.json and package-lock.json
mesaugat Nov 1, 2018
b3dae54
Prettier json files
mesaugat Nov 1, 2018
80c411f
Use single quotes
mesaugat Nov 2, 2018
cabac32
Revert to single quotes
mesaugat Nov 2, 2018
ffbd07b
Use 4 spaces when creating JSON files
mesaugat Nov 2, 2018
7f5bcce
Remove TODO comments
mesaugat Nov 2, 2018
e982815
Bring back TODO comments
mesaugat Nov 2, 2018
f4eae56
Add tslint:check as part of test script
mesaugat Nov 3, 2018
7655558
Remove conflicting rules from tslint.json as reported by tslint-confi…
mesaugat Nov 3, 2018
20af0d0
Use exact version for prettier
mesaugat Nov 3, 2018
879f286
Fix tests
mesaugat Nov 3, 2018
3c67000
tslint-disable for variable-name
mesaugat Nov 3, 2018
be52c93
Add no-unnecessary-semicolons to disabled rules
mesaugat Nov 3, 2018
cdc3f56
Disable arrow-return-shorthand
mesaugat Nov 3, 2018
3aa441f
Make comment spacing consistent
mesaugat Nov 3, 2018
40c0974
Update recommendations
mesaugat Nov 3, 2018
889387d
Single space before and after curly parens
mesaugat Nov 3, 2018
549aca2
Generate recommended_ruleset with single quotes
mesaugat Nov 3, 2018
33fdc87
Single quote 'rule' key
mesaugat Nov 3, 2018
9a787c9
Grammatical fix
mesaugat Nov 3, 2018
1341fce
Generate recommended ruleset
mesaugat Nov 3, 2018
c3fa6eb
Ignore recommended_ruleset.js
mesaugat Nov 3, 2018
545f88c
Format markdown files using prettier
mesaugat Nov 3, 2018
c0d7190
Format *.md files
mesaugat Nov 3, 2018
7b56fc7
Remove new line
mesaugat Nov 3, 2018
100ecbc
Add tslint:check before linting
mesaugat Nov 3, 2018
4f6f01f
Update .prettierignore
mesaugat Nov 3, 2018
73eaa78
Add husky and lint-staged
mesaugat Nov 3, 2018
b8f10df
Run prettier on pre-commit
mesaugat Nov 3, 2018
512cb05
Add prettier-vscode as a recommendation
mesaugat Nov 3, 2018
6bbed90
Escape asterisk
mesaugat Nov 4, 2018
d94c959
Remove extra space
mesaugat Nov 4, 2018
e4a22e6
Merge branch 'master' of github.com:Microsoft/tslint-microsoft-contri…
mesaugat Nov 4, 2018
13236c1
Remove unwanted string concatenations
mesaugat Nov 4, 2018
00c9b71
Merge branch 'master' of github.com:Microsoft/tslint-microsoft-contri…
mesaugat Nov 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build directory
dist/

# Definition files
*.d.ts

# NPM files
package.json
package-lock.json

# Test files
test-data/NoUnnecessarySemicolonsTestInput.ts

# Generated files
recommended_ruleset.js
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tabWidth: 4
printWidth: 140
singleQuote: true
16 changes: 8 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"EditorConfig.EditorConfig",
"eg2.tslint"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"EditorConfig.EditorConfig",
"eg2.tslint"
mesaugat marked this conversation as resolved.
Show resolved Hide resolved
]
}
13 changes: 2 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@
"request": "launch",
"name": "Run Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--no-timeouts",
"--colors",
"${workspaceFolder}/dist/src/tests/**/*.js"
]
"args": ["--no-timeouts", "--colors", "${workspaceFolder}/dist/src/tests/**/*.js"]
},
{
"type": "node",
"request": "launch",
"name": "Run TSLint Tests",
"program": "${workspaceFolder}/node_modules/tslint/bin/tslint",
"args": [
"--test",
"-r",
"dist/src",
"tests/**"
],
"args": ["--test", "-r", "dist/src", "tests/**"],
"outputCapture": "std"
}
]
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Use `npm run watch:run-tests` that will re-run tests (both Mocha and TSLint) and

This repo provides pre-configured launch tasks for VS Code debugging rules and tests.

* Pick `Run Mocha Tests` to debug rules which have Mocha unit tests inside `src/tests` folder.
* Pick `Run TSLint Tests` to debug rules that have tests in TSLint format inside `tests` folder.
- Pick `Run Mocha Tests` to debug rules which have Mocha unit tests inside `src/tests` folder.
- Pick `Run TSLint Tests` to debug rules that have tests in TSLint format inside `tests` folder.

**Node.js**

Expand Down
51 changes: 25 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ Alternately, you can download the files directly from GitHub: see [npm-5.2.1](ht
...or use the [`releases`](https://github.com/Microsoft/tslint-microsoft-contrib/tree/releases) branch, which is available online.
You can use that build by setting your npm version of `tslint-microsoft-contrib` to `git://github.com/Microsoft/tslint-microsoft-contrib.git#releases`.


## TSLint and corresponding tslint-microsoft-contrib version

| TSLint version | tslint-microsoft-contrib version |
| --- | --- |
| **>= 5.x** | 5.x (supporting TypeScript 2.3.x, >=2.4, 3.x)|
| **>= 4.x** | 4.x (supporting TypeScript 2.1.x) |
| **>= 3.2.x** | 2.x |
| **3.1.x** | unsupported |
| **3.0.x** | unsupported |
| **2.x** | 1.x |
| TSLint version | tslint-microsoft-contrib version |
| -------------- | --------------------------------------------- |
| **>= 5.x** | 5.x (supporting TypeScript 2.3.x, >=2.4, 3.x) |
| **>= 4.x** | 4.x (supporting TypeScript 2.1.x) |
| **>= 3.2.x** | 2.x |
| **3.1.x** | unsupported |
| **3.0.x** | unsupported |
| **2.x** | 1.x |

## Configuration

Expand All @@ -38,16 +37,16 @@ Add the new `rulesDirectory` to your `tslint` task:

```js
grunt.initConfig({
tslint: {
options: {
rulesDirectory: 'node_modules/tslint-microsoft-contrib',
configuration: grunt.file.readJSON("tslint.json")
},
files: {
src: ['src/file1.ts', 'src/file2.ts']
tslint: {
options: {
rulesDirectory: 'node_modules/tslint-microsoft-contrib',
configuration: grunt.file.readJSON('tslint.json')
},
files: {
src: ['src/file1.ts', 'src/file2.ts']
}
}
}
})
});
```

The `tslint.json` file does not change format when using this package. Just add our rule definitions to your existing `tslint.json` file.
Expand All @@ -56,10 +55,10 @@ The `tslint.json` file does not change format when using this package. Just add

There certainly are a lot of options! Here are some links to get you started.

* Easiest Option - Our recommended ruleset is here: [recommended_ruleset.js](recommended_ruleset.js). You can also easily extend the ruleset by adding `"extends": "tslint-microsoft-contrib"` to your configuration. Please note, the default rules require the `--type-check` and `--project` TSLint options. Also, please note that adding a rule to the recommended ruleset is considered backwards compatible. If you rely on version ranges in your dependencies then you may find that new rules being added to the product create violations and fail your build.
* A nice blog post on the MSDN secure development blog can be found here: [Automating Secure Development Lifecycle Checks in TypeScript with TSLint](https://blogs.msdn.microsoft.com/secdevblog/2016/05/11/automating-secure-development-lifecycle-checks-in-typescript-with-tslint/)
* A wiki briefly describing the SDL and related rules is here: [TSLint and the Microsoft Security Development Lifecycle](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/TSLint-and-the-Microsoft-Security-Development-Lifecycle)
* And our configuration file with all options is available here: [tslint.json](tslint.json)
- Easiest Option - Our recommended ruleset is here: [recommended_ruleset.js](recommended_ruleset.js). You can also easily extend the ruleset by adding `"extends": "tslint-microsoft-contrib"` to your configuration. Please note, the default rules require the `--type-check` and `--project` TSLint options. Also, please note that adding a rule to the recommended ruleset is considered backwards compatible. If you rely on version ranges in your dependencies then you may find that new rules being added to the product create violations and fail your build.
- A nice blog post on the MSDN secure development blog can be found here: [Automating Secure Development Lifecycle Checks in TypeScript with TSLint](https://blogs.msdn.microsoft.com/secdevblog/2016/05/11/automating-secure-development-lifecycle-checks-in-typescript-with-tslint/)
- A wiki briefly describing the SDL and related rules is here: [TSLint and the Microsoft Security Development Lifecycle](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/TSLint-and-the-Microsoft-Security-Development-Lifecycle)
- And our configuration file with all options is available here: [tslint.json](tslint.json)

### Supported Rules

Expand Down Expand Up @@ -1207,10 +1206,10 @@ There certainly are a lot of options! Here are some links to get you started.

These formatters assume that you use the UTF-8 file encoding. They may not work if you have a different encoding, especially if your encoding uses a 2-byte line ending (such as `\r\n` on Windows).

Formatter Name | Description | Since
:---------- | :------------ | -------------
`fix-no-require-imports`| This formatter automatically converts imports from the require syntax to the ES6 syntax. For example `import Utils = require('Utils');` becomes `import {Utils} from 'Utils';`. However, be warned that the fix assumes that your imported module exports the correct thing. If anything goes wrong with your exports then you'll get a compiler failure saying there is no default export. | 2.0.8
`fix-no-var-keyword` | This formatter automatically converts var variable declarations into let variable declarations found by the no-var-keyword rule. | 2.0.8
| Formatter Name | Description | Since |
| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| `fix-no-require-imports` | This formatter automatically converts imports from the require syntax to the ES6 syntax. For example `import Utils = require('Utils');` becomes `import {Utils} from 'Utils';`. However, be warned that the fix assumes that your imported module exports the correct thing. If anything goes wrong with your exports then you'll get a compiler failure saying there is no default export. | 2.0.8 |
| `fix-no-var-keyword` | This formatter automatically converts var variable declarations into let variable declarations found by the no-var-keyword rule. | 2.0.8 |

## Development

Expand Down
Loading