Skip to content

Commit

Permalink
Add new description of how to setup the dev environment #45
Browse files Browse the repository at this point in the history
  • Loading branch information
mosbth committed Feb 5, 2024
1 parent df95ddd commit 54be0b4
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .solution
Submodule .solution updated from e361df to f76083
113 changes: 113 additions & 0 deletions example/dev-environment/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2021,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"rules": {
"indent": [
2,
4,
{
"SwitchCase": 1
}
],
"linebreak-style": [
2,
"unix"
],
"eol-last": 2,
"no-trailing-spaces": 2,
"semi": [
2,
"always"
],
"camelcase": [
2,
{
"properties": "never"
}
],
"curly": [
2,
"all"
],
"brace-style": [
2,
"1tbs",
{
"allowSingleLine": true
}
],
"no-with": 2,
"keyword-spacing": [
2,
{}
],
"space-before-blocks": [
2,
"always"
],
"space-before-function-paren": [
2,
{
"anonymous": "ignore",
"named": "never"
}
],
"comma-spacing": [
2,
{
"after": true,
"before": false
}
],
"semi-spacing": [
2,
{
"before": false,
"after": true
}
],
"key-spacing": [
2,
{
"beforeColon": false,
"afterColon": true,
"mode": "minimum"
}
],
"padded-blocks": [
2,
"never"
],
"newline-after-var": [
2,
"always"
],
"max-len": [
2,
100
],
"comma-style": [
2,
"last"
],
"no-multi-str": 2,
"wrap-iife": [
"error",
"any"
],
"no-console": 0
}
}
77 changes: 77 additions & 0 deletions example/dev-environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Setup a local development environment with eslint
========================

The idea is to use eslint (eslint --fix) as a development tool to work with the code style and linting of your JavaScript code.



Base dir `me/` with `package.json`
------------------------

The base dir is `me/` and you install the tools there and you can access them in any sub folder.

Start by creating a `package.json`.

```
cd me
npm init -y
```



Install eslint
------------------------

Now we install the linter [eslint](https://eslint.org/) and save it as a dev tool.

```
npm install eslint --save-dev
```



Configure eslint
------------------------

You can use the same configuration as `dbwebb validate` does by copying that config file.

```
# Stay in the me directory
cp ../example/dev-environemnt/.eslintrc.json .
```

The configuration file decides what type of code standard you are to follow in this project.



Run eslint
------------------------

Add the following scripts to the script-section of your `package.json`.

```
"scripts": {
"eslint": "npx eslint . --ext js,mjs --no-eslintrc -c .eslintrc.json",
"eslint:fix": "npx eslint . --ext js,mjs --no-eslintrc -c .eslintrc.json --fix"
},
```

You can now see that the scripts are added by running this command.

```
npm run
```

You can now run the linter and the fixer like this.

```
npm run eslint
npm run eslint:fix
```



Install more
------------------------

You can now use the package.json at the me directory as you base for all your projects. Do not forget to add `--save` when you install the additional npm packages.
2 changes: 2 additions & 0 deletions example/lecture/2024-lp3/kmom03_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Repetera snabbt igenom vad som händer i kursmomentet.

* Fråga om dbwebb validate, `eslint` och `eslint --fix`

Att ta en backup, skriptet.



Använd databasen "classicalmodels"
Expand Down

0 comments on commit 54be0b4

Please sign in to comment.