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

Commit 98517eb

Browse files
Merge pull request #211 from peterblazejewicz/feat/209
✨ Migrate TSLint to ESLint. Closes #209
2 parents 0262194 + b78a0e0 commit 98517eb

22 files changed

+1085
-669
lines changed

.eslintignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# /node_modules/* in the project root is ignored by default
2+
# build artefacts
3+
dist/*
4+
coverage/*
5+
# data definition files
6+
**/*.d.ts
7+
# 3rd party libs
8+
/src/public/
9+
# custom definition files
10+
/src/types/

.eslintrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": ["plugin:@typescript-eslint/recommended"],
4+
"parserOptions": {
5+
"ecmaVersion": 2018,
6+
"sourceType": "module"
7+
},
8+
"rules": {
9+
"semi": ["error", "always"],
10+
"quotes": ["error", "double"]
11+
}
12+
}

.vscode/extensions.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"recommendations": [
3-
"ms-vscode.vscode-typescript-tslint-plugin",
4-
"ms-azuretools.vscode-cosmosdb",
5-
]
6-
}
2+
"recommendations": ["dbaeumer.vscode-eslint", "ms-azuretools.vscode-cosmosdb"]
3+
}

.vscode/settings.json

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"search.exclude": {
4-
"**/node_modules": true,
5-
"**/bower_components": true,
6-
"**/dist": true,
7-
"**/coverge": true
8-
},
9-
"typescript.referencesCodeLens.enabled": true,
10-
"tslint.ignoreDefinitionFiles": false,
11-
"tslint.autoFixOnSave": true,
12-
"tslint.exclude": "**/node_modules/**/*",
13-
"appService.zipIgnorePattern": [
14-
".vscode{,/**}"
15-
],
16-
"appService.deploySubpath": ""
17-
}
3+
"eslint.autoFixOnSave": true,
4+
"eslint.validate": [
5+
"javascript",
6+
{ "language": "typescript", "autoFix": true }
7+
],
8+
"editor.formatOnSave": true,
9+
"[javascript]": {
10+
"editor.formatOnSave": false
11+
},
12+
"[typescript]": {
13+
"editor.formatOnSave": false
14+
},
15+
"[markdown]": {
16+
"editor.formatOnSave": false
17+
},
18+
"search.exclude": {
19+
"**/node_modules": true,
20+
"**/bower_components": true,
21+
"**/dist": true,
22+
"**/coverge": true
23+
},
24+
"typescript.referencesCodeLens.enabled": true,
25+
"appService.zipIgnorePattern": [".vscode{,/**}"],
26+
"appService.deploySubpath": ""
27+
}

README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ We will try to keep this as up-to-date as possible, but community contributions
2323
- [Type Definition (`.d.ts`) Files](#type-definition-dts-files)
2424
- [Debugging](#debugging)
2525
- [Testing](#testing)
26-
- [TSLint](#tslint)
26+
- [ESLint](#eslint)
2727
- [Dependencies](#dependencies)
2828
- [`dependencies`](#dependencies-1)
2929
- [`devDependencies`](#devdependencies)
@@ -203,7 +203,9 @@ The full folder structure of this app is explained below:
203203
| jest.config.js | Used to configure Jest running tests written in TypeScript |
204204
| package.json | File that contains npm dependencies as well as [build scripts](#what-if-a-library-isnt-on-definitelytyped) |
205205
| tsconfig.json | Config settings for compiling server code written in TypeScript |
206-
| tslint.json | Config settings for TSLint code style checking |
206+
| tsconfig.tests.json | Config settings for compiling tests written in TypeScript |
207+
| .eslintrc | Config settings for ESLint code style checking |
208+
| .eslintignore | Config settings for paths to exclude from linting |
207209

208210
## Building the project
209211
It is rare for JavaScript projects not to have some kind of build pipeline these days, however Node projects typically have the least amount of build configuration.
@@ -271,7 +273,7 @@ Below is a list of all the scripts this template has available:
271273
| Npm Script | Description |
272274
| ------------------------- | ------------------------------------------------------------------------------------------------- |
273275
| `start` | Does the same as 'npm run serve'. Can be invoked with `npm start` |
274-
| `build` | Full build. Runs ALL build tasks (`build-sass`, `build-ts`, `tslint`, `copy-static-assets`) |
276+
| `build` | Full build. Runs ALL build tasks (`build-sass`, `build-ts`, `lint`, `copy-static-assets`) |
275277
| `serve` | Runs node on `dist/server.js` which is the apps entry point |
276278
| `watch-node` | Runs node with nodemon so the process restarts if it crashes. Used in the main watch task |
277279
| `watch` | Runs all watch tasks (TypeScript, Sass, Node). Use this if you're not touching static assets. |
@@ -281,7 +283,7 @@ Below is a list of all the scripts this template has available:
281283
| `watch-ts` | Same as `build-ts` but continuously watches `.ts` files and re-compiles when needed |
282284
| `build-sass` | Compiles all `.scss` files to `.css` files |
283285
| `watch-sass` | Same as `build-sass` but continuously watches `.scss` files and re-compiles when needed |
284-
| `tslint` | Runs TSLint on project files |
286+
| `lint` | Runs ESLint on project files |
285287
| `copy-static-assets` | Calls script that copies JS libs, fonts, and images to dist directory |
286288
| `debug` | Performs a full build and then serves the app in watch mode |
287289
| `serve-debug` | Runs the app with the --inspect flag |
@@ -461,34 +463,32 @@ Note this will also generate a coverage report.
461463
Writing tests for web apps has entire books dedicated to it and best practices are strongly influenced by personal style, so I'm deliberately avoiding discussing how or when to write tests in this guide.
462464
However, if prescriptive guidance on testing is something that you're interested in, [let me know](https://www.surveymonkey.com/r/LN2CV82), I'll do some homework and get back to you.
463465

464-
## TSLint
465-
TSLint is a code linter which mainly helps catch minor code quality and style issues.
466-
TSLint is very similar to ESLint or JSLint but is built with TypeScript in mind.
466+
## ESLint
467+
ESLint is a code linter which mainly helps catch quickly minor code quality and style issues.
467468

468-
### TSLint rules
469-
Like most linters, TSLint has a wide set of configurable rules as well as support for custom rule sets.
470-
All rules are configured through `tslint.json`.
469+
### ESLint rules
470+
Like most linters, ESLint has a wide set of configurable rules as well as support for custom rule sets.
471+
All rules are configured through `.eslintrc` configuration file.
471472
In this project, we are using a fairly basic set of rules with no additional custom rules.
472-
The settings are largely based off the TSLint settings that we use to develop TypeScript itself.
473473

474-
### Running TSLint
475-
Like the rest of our build steps, we use npm scripts to invoke TSLint.
476-
To run TSLint you can call the main build script or just the TSLint task.
474+
### Running ESLint
475+
Like the rest of our build steps, we use npm scripts to invoke ESLint.
476+
To run ESLint you can call the main build script or just the ESLint task.
477477
```
478-
npm run build // runs full build including TSLint
479-
npm run tslint // runs only TSLint
478+
npm run build // runs full build including ESLint
479+
npm run lint // runs only ESLint
480480
```
481-
Notice that TSLint is not a part of the main watch task.
482-
It can be annoying for TSLint to clutter the output window while in the middle of writing a function, so I elected to only run it only during the full build.
483-
If you are interested in seeing TSLint feedback as soon as possible, I strongly recommend the [TSLint extension in VS Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin).
481+
Notice that ESLint is not a part of the main watch task.
482+
483+
If you are interested in seeing ESLint feedback as soon as possible, I strongly recommend the [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
484484

485485
### VSCode Extensions
486486

487487
To enhance your development experience while working in VSCode we also provide you a list of the suggested extensions for working with this project:
488488

489489
![Suggested Extensions In VSCode](https://user-images.githubusercontent.com/14539/34583539-6f290a30-f198-11e7-8804-30f40d418e20.png)
490490

491-
- [TSLint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint)
491+
- [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
492492
- [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
493493
- [Azure Cosmos DB](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb)
494494
- [Azure App Service](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureappservice)
@@ -539,7 +539,7 @@ In that file you'll find two sections:
539539
| supertest | HTTP assertion library. |
540540
| ts-jest | A preprocessor with sourcemap support to help use TypeScript with Jest.|
541541
| ts-node | Enables directly running TS files. Used to run `copy-static-assets.ts` |
542-
| tslint | Linter (similar to ESLint) for TypeScript files |
542+
| eslint | Linter for JavaScript and TypeScript files |
543543
| typescript | JavaScript compiler/type checker that boosts JavaScript productivity |
544544

545545
To install or update these dependencies you can use `npm install` or `npm update`.

0 commit comments

Comments
 (0)