Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.

Commit 38c6e83

Browse files
Update tutorials
1 parent 9c4cca5 commit 38c6e83

File tree

4 files changed

+48
-41
lines changed

4 files changed

+48
-41
lines changed

tutorial/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@
33
When configuring js-coding-standards, please keep the following in mind:
44

55
- Prefer _.eslintrc.js_ format over YAML/JSON
6-
> JSON cannot contain comments or other simple code, and YAML requires custom parser. Using standard node.js module format speeds the whole process up.
6+
> JSON cannot contain comments or other simple code, and YAML requires custom parser. Using standard node.js module format speeds the whole linting process up.
77
88
- Always extend only from **one environment configuration** per _.eslintrc.js_
9-
> Some environments have conflicting configurations - you **will** experience weird issues if you include ie. both nodejs and react environments into a single _.eslintrc.js_ file.
10-
> If your project consists of both React and node.js code, put them into separate folders and create _.eslintrc.js_ file for each of those folders.
9+
> Some environment configuration files in this ruleset have conflicting rule configurations - you **will** experience weird issues if you include ie. both nodejs and react environments into a single _.eslintrc.js_ file.
10+
>
11+
> If your project consists of both React and Node.js code, put them into separate folders and create _.eslintrc.js_ file for each of those folders.
1112
1213
- Do not include extensions when extending
1314
> You should not include the file extension in your `extends:` properties - the format in which this ruleset is written should be an implementation detail for ESLint to figure out.
1415
>
15-
> - Good: `@strv/javascript/environments/nodejs/v6`
16-
> - Bad: `@strv/javascript/environments/nodejs/v6.js`
16+
> - Good: `@strv/javascript/environments/nodejs/v8`
17+
> - Bad: `@strv/javascript/environments/nodejs/v8.js`
1718
1819
- Extend from the `optional` rulesets after you extend from the main, version-specific environment ruleset
19-
> In other words, if you decide to include ie. `@strv/javascript/environments/nodejs/optional`, include it **after** you have included `@strv/javascript/environments/nodejs/v6`.
20+
> In other words, if you decide to include ie. `@strv/javascript/environments/nodejs/optional`, include it **after** you have included `@strv/javascript/environments/nodejs/v8`.
2021
2122
- Some rules are **meant** to be disabled, but only for some folders/files
22-
> For example, the rule `no-process-env` is enabled by default because accessing any property on `process.env` object causes an expensive C-level function call. However, using `process.env` is the recommended way to manage application configuration. Therefore, it is OK to turn this rule off for a single folder/file where you gather all the required configuration options from `process.env` and export them in a module. The rest of your application no longer needs to access `process.env` directly and instead reads the configuration from the module.
23+
> For example, the rule `no-process-env` is enabled by default because accessing any any property on `process.env` object causes an expensive C-level function call. However, using `process.env` is the recommended way to manage application configuration. Therefore, some configuration files disable this rule for all files located in a directory named _config_ or _configuration_. Here, you gather all the required configuration options from `process.env` and export them in a module. The rest of your application no longer needs to access `process.env` directly and instead reads the configuration from that module.
2324
2425
- Always consider re-configuring a rule rather than disabling it completely
2526
> If a rule does not quite fit your exiting codebase and fixing the issues would take considerable amount of time/energy, please consider first if the rule could be re-configured to suit your project's current style, rather than disabling it right away.

tutorial/editor-integrations.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
[atom-linter]: https://atom.io/packages/linter
2+
[atom-linter-eslint]: https://atom.io/packages/linter-eslint
3+
[vscode-eslint]: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
4+
[subl-packagecontrol]: https://packagecontrol.io
5+
[subl-linter]: https://packagecontrol.io/packages/SublimeLinter
6+
[subl-linter-eslint]: https://packagecontrol.io/packages/SublimeLinter-contrib-eslint
7+
[subl-eslint-formatter]: https://packagecontrol.io/packages/ESLint-Formatter
8+
[webstorm-eslint]: https://www.jetbrains.com/help/webstorm/2016.3/using-javascript-code-quality-tools.html#ESLint
9+
[webstorm-eslint-autofix]: https://blog.jetbrains.com/webstorm/2016/09/webstorm-2016-3-eap-163-3983
10+
11+
112
# ESLint integrations with your IDE/editors
213

314
To make the whole developer experience more pleasant and convenient, it is important to configure your code editor of choice integrate with ESLint. The following can be achieved with most editors:
@@ -73,23 +84,14 @@ WebStorm has built-in support for ESLint issue reporting. Auto fixing is only su
7384
To enable ESLint reporter, [follow the guide][webstorm-eslint] on WebStorm's support page.
7485
To use the new autofix feature, [read their blog post][webstorm-eslint-autofix] on the topic.
7586

76-
To use autofix on save feature
77-
1. Go to `Preferences` -> `Tools` -> `File watchers`
78-
2. Click to add (plus) button and choose custom template
79-
3. Name it for example `eslint`
80-
4. File type `javascript`
81-
5. Program will be your path to eslint binary for example `/Users/[yourusername]/git/[yourproject]/node_modules/.bin/eslint`
82-
6. Arguments `--fix $FilePath$`
83-
7. Working directory `$ProjectFileDir$`
84-
8. Show console `never` (if you don't want to see console when --fix command find eslint errors)
85-
9. Check `Trigger watcher regardless of syntax errors` and uncheck `Immediate file synchronization`
87+
To use autofix on save feature:
8688

87-
[atom-linter]: https://atom.io/packages/linter
88-
[atom-linter-eslint]: https://atom.io/packages/linter-eslint
89-
[vscode-eslint]: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
90-
[subl-packagecontrol]: https://packagecontrol.io
91-
[subl-linter]: https://packagecontrol.io/packages/SublimeLinter
92-
[subl-linter-eslint]: https://packagecontrol.io/packages/SublimeLinter-contrib-eslint
93-
[subl-eslint-formatter]: https://packagecontrol.io/packages/ESLint-Formatter
94-
[webstorm-eslint]: https://www.jetbrains.com/help/webstorm/2016.3/using-javascript-code-quality-tools.html#ESLint
95-
[webstorm-eslint-autofix]: https://blog.jetbrains.com/webstorm/2016/09/webstorm-2016-3-eap-163-3983
89+
1. Go to `Preferences` -> `Tools` -> `File watchers`
90+
1. Click the `Add` (+) button and choose custom template
91+
1. Name it for example `eslint`
92+
1. Set file type to `javascript`
93+
1. Program will be your path to eslint binary for example `/Users/[yourusername]/git/[yourproject]/node_modules/.bin/eslint`
94+
1. Arguments `--fix $FilePath$`
95+
1. Working directory `$ProjectFileDir$`
96+
1. Show console `never` (if you don't want to see the console when `--fix` command finds errors)
97+
1. Check `Trigger watcher regardless of syntax errors` and uncheck `Immediate file synchronization`

tutorial/mocha-eslintrc.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

tutorial/nodejs-eslintrc.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,26 @@
44
// directory, or a subdirectory if your project consists of both node.js and browser code.
55
module.exports = {
66
extends: [
7-
'@strv/javascript/environments/nodejs/v6',
7+
'@strv/javascript/environments/nodejs/v8',
88
'@strv/javascript/environments/nodejs/optional',
99
'@strv/javascript/coding-styles/recommended',
1010
],
11+
12+
// As of ESLint 4.1, you no longer need to use separate, per-directory .eslintrc.js files and
13+
// instead control per-folder overrides from your central .eslintrc.js file using the overrides
14+
// array.
15+
// See the original blog post on the feature:
16+
// https://eslint.org/blog/2017/06/eslint-v4.1.0-released
17+
overrides: [{
18+
files: [
19+
'test/**',
20+
],
21+
env: {
22+
mocha: true,
23+
},
24+
25+
rules: {
26+
'func-names': 0,
27+
},
28+
}],
1129
}

0 commit comments

Comments
 (0)