Skip to content

Commit

Permalink
[Docs] Fix tutorials for new ESLint config
Browse files Browse the repository at this point in the history
  • Loading branch information
fer22f committed Oct 26, 2019
1 parent 1ee4294 commit 044bfbd
Show file tree
Hide file tree
Showing 29 changed files with 3,358 additions and 382 deletions.
4 changes: 2 additions & 2 deletions docs/tutorials/mongodb-todo-list/1-installation.md
Expand Up @@ -35,7 +35,7 @@ my-app/
scripts/
package.json
tsconfig.*.json
tslint.json
.eslintrc.js
```

The outer `my-app` root directory is just a container for your project.
Expand All @@ -48,7 +48,7 @@ The outer `my-app` root directory is just a container for your project.
- The inner `scripts/` folder contains scripts intended to be called from the command line (ex: create-user).
- The `package.json` lists the dependencies and commands of the project.
- The `tsconfig.*.json` files list the TypeScript compiler configuration for each `npm` command.
- Finally the linting configuration can be found in the `tslint.json` file.
- Finally the linting configuration can be found in the `.eslintrc.js` file.

> **TypeScript**
>
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/multi-user-todo-list/6-todos-and-ownership.md
Expand Up @@ -48,7 +48,7 @@ Update the api controller.
})
async deleteTodo(ctx: Context) {
const todo = await getRepository(Todo).findOne({
id: (ctx.request.params as any).id,
id: +ctx.request.params,

This comment has been minimized.

Copy link
@OrkhanAlikhanov

OrkhanAlikhanov Nov 11, 2019

id is missing now. Btw thanks for migration

This comment has been minimized.

Copy link
@fer22f

fer22f Nov 12, 2019

Author Contributor

Oh, missed that one!

// Do not return the todo if it does not belong to the current user.
owner: ctx.user
});
Expand All @@ -60,4 +60,4 @@ Update the api controller.
}
```

The application is now working properly.
The application is now working properly.
4 changes: 2 additions & 2 deletions docs/tutorials/simple-todo-list/1-installation.md
Expand Up @@ -34,7 +34,7 @@ my-app/
ormconfig.js
package.json
tsconfig.*.json
tslint.json
.eslintrc.js
```

The outer `my-app` root directory is just a container for your project.
Expand All @@ -48,7 +48,7 @@ The outer `my-app` root directory is just a container for your project.
- The `ormconfig.js` file defines the configuration and credentials of the database(s) connection(s). They can also be passed through environment variables.
- The `package.json` lists the dependencies and commands of the project.
- The `tsconfig.*.json` files list the TypeScript compiler configuration for each `npm` command.
- Finally the linting configuration can be found in the `tslint.json` file.
- Finally the linting configuration can be found in the `.eslintrc.js` file.

> **TypeScript**
>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/simple-todo-list/5-the-rest-api.md
Expand Up @@ -72,7 +72,7 @@ Add the create and delete features.
@Delete('/todos/:id')
async deleteTodo(ctx: Context) {
// Get the todo with the id given in the URL if it exists.
const todo = await getRepository(Todo).findOne({ id: parseInt(ctx.request.params.id, 10) });
const todo = await getRepository(Todo).findOne({ id: +ctx.request.params.id });

// Return a 404 Not Found response if no such todo exists.
if (!todo) {
Expand Down
Expand Up @@ -56,7 +56,7 @@ export class ApiController {
type: 'object',
})
async deleteTodo(ctx: Context) {
const todo = await getRepository(Todo).findOne({ id: (ctx.request.params as any).id });
const todo = await getRepository(Todo).findOne({ id: +ctx.request.params.id });
if (!todo) {
return new HttpResponseNotFound();
}
Expand Down
43 changes: 43 additions & 0 deletions samples/tutorials/01-simple-todo-list/.eslintrc.js
@@ -0,0 +1,43 @@
module.exports = {
env: {
'browser': true,
'es6': true,
'node': true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: [
'@typescript-eslint'
],
rules: {
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error', { 'accessibility': 'no-public' }
],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/quotes': ['error', 'single'],
'arrow-parens': ['error', 'as-needed'],
'max-classes-per-file': 'off',
'no-console': 'off',
'no-duplicate-imports': 'error',
'no-empty': 'off',
'no-shadow': 'off',
'comma-dangle': 'off',
'sort-keys': 'off',
'@typescript-eslint/no-unused-vars': ['error', { 'args': 'none' }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/require-await': 'off'
}
};

0 comments on commit 044bfbd

Please sign in to comment.