Skip to content

Commit 07be75d

Browse files
committed
betterments 9c
1 parent e111148 commit 07be75d

File tree

3 files changed

+121
-73
lines changed

3 files changed

+121
-73
lines changed

src/content/9/en/part9b.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ console.log(calculateBmi(180, 74))
501501
should print the following message:
502502

503503
```shell
504-
Normal (healthy weight)
504+
Normal range
505505
```
506506

507507
Create an npm script for running the program with the command *npm run calculateBmi*.
@@ -531,7 +531,8 @@ For the Result object, you should create an [interface](https://www.typescriptla
531531
If you call the function with parameters *[3, 0, 2, 4.5, 0, 3, 1]* and *2*, it should return:
532532

533533
```js
534-
{ periodLength: 7,
534+
{
535+
periodLength: 7,
535536
trainingDays: 5,
536537
success: false,
537538
rating: 2,
@@ -560,7 +561,8 @@ and:
560561
```shell
561562
$ npm run calculateExercises 2 1 0 2 4.5 0 3 1 0 4
562563

563-
{ periodLength: 9,
564+
{
565+
periodLength: 9,
564566
trainingDays: 6,
565567
success: false,
566568
rating: 2,
@@ -815,7 +817,7 @@ The response is a JSON of the form:
815817
{
816818
weight: 72,
817819
height: 180,
818-
bmi: "Normal (healthy weight)"
820+
bmi: "Normal range"
819821
}
820822
```
821823

@@ -898,6 +900,7 @@ npm install --save-dev eslint @eslint/js @types/eslint__js typescript typescript
898900
We will configure ESlint to [disallow explicit any]( https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-explicit-any.md). Write the following rules to *eslint.config.mjs*:
899901
900902
```js
903+
import eslint from '@eslint/js';
901904
import tseslint from 'typescript-eslint';
902905

903906
export default tseslint.config({
@@ -939,12 +942,18 @@ Now lint will complain if we try to define a variable of type *any*:
939942
940943
[@typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) has a lot of TypeScript-specific ESlint rules, but you can also use all basic ESlint rules in TypeScript projects. For now, we should probably go with the recommended settings, and we will modify the rules as we go along whenever we find something we want to change the behavior of.
941944
942-
On top of the recommended settings, we should try to get familiar with the coding style required in this part and <i>set the semicolon at the end of each line of code to be required</i>.
945+
On top of the recommended settings, we should try to get familiar with the coding style required in this part and <i>set the semicolon at the end of each line of code to be required</i>. For that, we should install and configure [@stylistic/eslint-plugin](https://eslint.style/packages/default):
943946
944-
So we will use the following *eslint.config.mjs*
947+
```bash
948+
npm install --save-dev @stylistic/eslint-plugin
949+
```
950+
951+
Our final *eslint.config.mjs* looks as follows:
945952
946953
```js
954+
import eslint from '@eslint/js';
947955
import tseslint from 'typescript-eslint';
956+
import stylistic from "@stylistic/eslint-plugin";
948957

949958
export default tseslint.config({
950959
files: ['**/*.ts'],
@@ -958,10 +967,13 @@ export default tseslint.config({
958967
tsconfigRootDir: import.meta.dirname,
959968
},
960969
},
970+
plugins: {
971+
"@stylistic": stylistic,
972+
},
961973
rules: {
974+
'@stylistic/semi': 'error',
962975
'@typescript-eslint/no-unsafe-assignment': 'error',
963976
'@typescript-eslint/no-explicit-any': 'error',
964-
'@typescript-eslint/semi': 'error',
965977
'@typescript-eslint/explicit-function-return-type': 'off',
966978
'@typescript-eslint/explicit-module-boundary-types': 'off',
967979
'@typescript-eslint/restrict-template-expressions': 'off',

0 commit comments

Comments
 (0)