-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new description of how to setup the dev environment #45
- Loading branch information
Showing
4 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
Submodule .solution
updated
from e361df to f76083
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters