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

Commit 9084d54

Browse files
mesaugatJosh Goldberg
authored and
Josh Goldberg
committed
Use prettier to format source files (#623)
* Add prettier, prettierrc and prettierignore * Add tslint-config-prettier to avoid tslint and prettier conflicts * First prettier run * Prettify json files * Ignore package.json and package-lock.json * Prettier json files * Use single quotes * Revert to single quotes * Use 4 spaces when creating JSON files * Remove TODO comments * Bring back TODO comments * Add tslint:check as part of test script * Remove conflicting rules from tslint.json as reported by tslint-config-prettier * Use exact version for prettier * Fix tests * tslint-disable for variable-name * Add no-unnecessary-semicolons to disabled rules * Disable arrow-return-shorthand * Make comment spacing consistent * Update recommendations * Single space before and after curly parens * Generate recommended_ruleset with single quotes * Single quote 'rule' key * Grammatical fix * Generate recommended ruleset * Ignore recommended_ruleset.js * Format markdown files using prettier * Format *.md files * Remove new line * Add tslint:check before linting * Update .prettierignore * Add husky and lint-staged * Run prettier on pre-commit * Add prettier-vscode as a recommendation * Escape asterisk * Remove extra space * Remove unwanted string concatenations
1 parent ac7143b commit 9084d54

File tree

393 files changed

+16244
-15567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+16244
-15567
lines changed

.prettierignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Build directory
2+
dist/
3+
4+
# Definition files
5+
*.d.ts
6+
7+
# NPM files
8+
package.json
9+
package-lock.json
10+
11+
# Test files
12+
test-data/NoUnnecessarySemicolonsTestInput.ts
13+
14+
# Generated files
15+
recommended_ruleset.js

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tabWidth: 4
2+
printWidth: 140
3+
singleQuote: true

.vscode/extensions.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
// See http://go.microsoft.com/fwlink/?LinkId=827846
3-
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
6-
"EditorConfig.EditorConfig",
7-
"eg2.tslint"
8-
]
9-
}
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
6+
"EditorConfig.EditorConfig",
7+
"eg2.tslint",
8+
"esbenp.prettier-vscode"
9+
]
10+
}

.vscode/launch.json

+2-11
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,14 @@
66
"request": "launch",
77
"name": "Run Mocha Tests",
88
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
9-
"args": [
10-
"--no-timeouts",
11-
"--colors",
12-
"${workspaceFolder}/dist/src/tests/**/*.js"
13-
]
9+
"args": ["--no-timeouts", "--colors", "${workspaceFolder}/dist/src/tests/**/*.js"]
1410
},
1511
{
1612
"type": "node",
1713
"request": "launch",
1814
"name": "Run TSLint Tests",
1915
"program": "${workspaceFolder}/node_modules/tslint/bin/tslint",
20-
"args": [
21-
"--test",
22-
"-r",
23-
"dist/src",
24-
"tests/**"
25-
],
16+
"args": ["--test", "-r", "dist/src", "tests/**"],
2617
"outputCapture": "std"
2718
}
2819
]

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Use `npm run watch:run-tests` that will re-run tests (both Mocha and TSLint) and
4040

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

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

4646
**Node.js**
4747

README.md

+25-26
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ Alternately, you can download the files directly from GitHub: see [npm-5.2.1](ht
1818
...or use the [`releases`](https://github.com/Microsoft/tslint-microsoft-contrib/tree/releases) branch, which is available online.
1919
You can use that build by setting your npm version of `tslint-microsoft-contrib` to `git://github.com/Microsoft/tslint-microsoft-contrib.git#releases`.
2020

21-
2221
## TSLint and corresponding tslint-microsoft-contrib version
2322

24-
| TSLint version | tslint-microsoft-contrib version |
25-
| --- | --- |
26-
| **>= 5.x** | 5.x (supporting TypeScript 2.3.x, >=2.4, 3.x)|
27-
| **>= 4.x** | 4.x (supporting TypeScript 2.1.x) |
28-
| **>= 3.2.x** | 2.x |
29-
| **3.1.x** | unsupported |
30-
| **3.0.x** | unsupported |
31-
| **2.x** | 1.x |
23+
| TSLint version | tslint-microsoft-contrib version |
24+
| -------------- | --------------------------------------------- |
25+
| **>= 5.x** | 5.x (supporting TypeScript 2.3.x, >=2.4, 3.x) |
26+
| **>= 4.x** | 4.x (supporting TypeScript 2.1.x) |
27+
| **>= 3.2.x** | 2.x |
28+
| **3.1.x** | unsupported |
29+
| **3.0.x** | unsupported |
30+
| **2.x** | 1.x |
3231

3332
## Configuration
3433

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

3938
```js
4039
grunt.initConfig({
41-
tslint: {
42-
options: {
43-
rulesDirectory: 'node_modules/tslint-microsoft-contrib',
44-
configuration: grunt.file.readJSON("tslint.json")
45-
},
46-
files: {
47-
src: ['src/file1.ts', 'src/file2.ts']
40+
tslint: {
41+
options: {
42+
rulesDirectory: 'node_modules/tslint-microsoft-contrib',
43+
configuration: grunt.file.readJSON('tslint.json')
44+
},
45+
files: {
46+
src: ['src/file1.ts', 'src/file2.ts']
47+
}
4848
}
49-
}
50-
})
49+
});
5150
```
5251

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

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

59-
* 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.
60-
* 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/)
61-
* 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)
62-
* And our configuration file with all options is available here: [tslint.json](tslint.json)
58+
- 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.
59+
- 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/)
60+
- 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)
61+
- And our configuration file with all options is available here: [tslint.json](tslint.json)
6362

6463
### Supported Rules
6564

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

12081207
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).
12091208

1210-
Formatter Name | Description | Since
1211-
:---------- | :------------ | -------------
1212-
`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
1213-
`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
1209+
| Formatter Name | Description | Since |
1210+
| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
1211+
| `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 |
1212+
| `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 |
12141213

12151214
## Development
12161215

0 commit comments

Comments
 (0)