Skip to content

Commit 0b633fc

Browse files
committed
Add info about devDependencies
1 parent 2a15726 commit 0b633fc

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

src/content/3/en/part3d.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ There are usually constraints that we want to apply to the data that is stored i
1313
app.post('/api/notes', (request, response) => {
1414
const body = request.body
1515
// highlight-start
16-
if (body.content === undefined) {
16+
if (!body.content) {
1717
return response.status(400).json({ error: 'content missing' })
1818
}
1919
// highlight-end
@@ -214,12 +214,34 @@ In compiled statically typed languages like Java, IDEs like NetBeans can point o
214214

215215
In the JavaScript universe, the current leading tool for static analysis (aka "linting") is [ESlint](https://eslint.org/).
216216

217-
Let's install ESlint as a development dependency to the notes backend project with the command:
217+
Let's add ESLint as a <i>development dependency</i> for the backend. Development dependencies are tools that are only needed during the development of the application. For example, tools related to testing are such dependencies. When the application is run in production mode, development dependencies are not needed.
218+
219+
Install ESLint as a development dependency for the backend with the command:
218220

219221
```bash
220222
npm install eslint @eslint/js --save-dev
221223
```
222224

225+
The contents of the package.json file will change as follows:
226+
227+
```js
228+
{
229+
//...
230+
"dependencies": {
231+
"dotenv": "^16.4.7",
232+
"express": "^4.21.2",
233+
"mongoose": "^8.11.0",
234+
"morgan": "^1.10.0"
235+
},
236+
"devDependencies": { // highlight-line
237+
"@eslint/js": "^9.22.0", // highlight-line
238+
"eslint": "^9.22.0" // highlight-line
239+
}
240+
}
241+
```
242+
243+
The command added a <i>devDependencies</i> section to the file and included the packages <i>eslint</i> and <i>@eslint/js</i>, and installed the required libraries into the <i>node_modules</i> directory.
244+
223245
After this we can initialize a default ESlint configuration with the command:
224246

225247
```bash

src/content/3/fi/osa3d.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Sovelluksen tietokantaan tallettamalle datan muodolle on usein tarve asettaa joi
1313
app.post('/api/notes', (request, response) => {
1414
const body = request.body
1515
// highlight-start
16-
if (body.content === undefined) {
16+
if (!body.content) {
1717
return response.status(400).json({ error: 'content missing' })
1818
}
1919
// highlight-end
@@ -202,12 +202,34 @@ Staattisesti tyypitetyissä, käännettävissä kielissä (esim. Javassa) ohjelm
202202

203203
JavaScript-maailmassa tämän hetken johtava työkalu staattiseen analyysiin eli "linttaukseen" on [ESLint](https://eslint.org/).
204204

205-
Asennetaan ESLint backendiin kehitysaikaiseksi riippuvuudeksi:
205+
Lisätään ESLint backendin <i>kehitysaikaiseksi riippuvuudeksi</i> (development dependency). Kehitysaikaisilla riippuvuuksilla tarkoitetaan työkaluja, joita tarvitaan ainoastaan sovellusta kehittäessä. Esimerkiksi testaukseen liittyvät työkalut ovat tällaisia. Kun sovellusta suoritetaan tuotantomoodissa, ei kehitysaikaisia riippuvuuksia tarvita.
206+
207+
Asennetaan ESLint backendiin kehitysaikaiseksi riippuvuudeksi komennolla:
206208

207209
```bash
208210
npm install eslint @eslint/js --save-dev
209211
```
210212

213+
Tiedoston package.json sisältö muuttuu seuraavasti:
214+
215+
```js
216+
{
217+
//...
218+
"dependencies": {
219+
"dotenv": "^16.4.7",
220+
"express": "^4.21.2",
221+
"mongoose": "^8.11.0",
222+
"morgan": "^1.10.0"
223+
},
224+
"devDependencies": { // highlight-line
225+
"@eslint/js": "^9.22.0", // highlight-line
226+
"eslint": "^9.22.0" // highlight-line
227+
}
228+
}
229+
```
230+
231+
Komento lisäsi siis tiedostoon <i>devDependencies</i>-osion ja sinne paketit <i>eslint</i> ja <i>@eslint/js</i> sekä asensi tarvittavat kirjastot <i>node_modules</i>-hakemistoon.
232+
211233
Tämän jälkeen voidaan muodostaa alustava ESLint-konfiguraatio:
212234

213235
```bash

0 commit comments

Comments
 (0)