@soleil-se/eslint-config 0.3.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+ Alla förändringar i detta repository antecknas här.
3
+
4
+ Formatet baseras på [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ och projektet använder [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.0.0] - 2020-01-13
8
+ ### Ändrat
9
+ - Uppdaterat till ESLint 6.
10
+
11
+ ## [0.3.3] - 2019-12-06
12
+ ### Ändrat
13
+ - Det får nu vara max 3 attribut per rad i Vue (`vue/max-attributes-per-line`).
14
+
15
+ ## [0.3.2] - 2019-06-03
16
+ ### Fixat
17
+ - Lagt till `server_src/api` i server på den globala configen.
18
+
19
+ ## [0.3.1] - 2019-05-20
20
+ ### Ändrat
21
+ - Slagit av `global-require` för att kunna skriva `require` innanför IIFE i `src/index.js` i en WebApp.
22
+
23
+ ## [0.3.0] - 2019-05-20
24
+ ### Nytt
25
+ - Lagt till en global config som kan användas i roten av ett projekt som använder standardstrukturen och `@soleil/sv-gulp-build@^3.0.0`.
26
+
27
+
28
+
package/LICENSE.md CHANGED
@@ -1 +1 @@
1
- (c) Copyright 2019 Soleil AB, all rights reserved.
1
+ (c) Copyright 2020 Soleil AB, all rights reserved.
package/README.md CHANGED
@@ -21,26 +21,27 @@ https://eslint.org/docs/rules/
21
21
 
22
22
  - [1. Innehållsförteckning](#1-innehållsförteckning)
23
23
  - [2. Installera](#2-installera)
24
- - [3. Config](#3-config)
25
- - [3.1 Konfigurationsfiler](#31-konfigurationsfiler)
26
- - [3.2. Importera config](#32-importera-config)
27
- - [3. Editors](#3-editors)
28
- - [3.1. VS Code](#31-vs-code)
29
- - [3.3.1. End of line](#331-end-of-line)
30
- - [3.3.2. Autofix](#332-autofix)
31
- - [3.3.3. Max length](#333-max-length)
32
- - [3.3.4. Velocity](#334-velocity)
33
- - [3.3.5. Vue](#335-vue)
34
- - [3.3.6 Global konfig i underkatalog](#336-global-konfig-i-underkatalog)
35
- - [3.3.7. Komplett config](#337-komplett-config)
36
- - [4. CLI](#4-cli)
37
- - [5. Git](#5-git)
38
- - [6. Byggmiljö](#6-byggmiljö)
39
- - [7. Undantag](#7-undantag)
40
- - [7.1. Server - ES2015+](#71-server---es2015)
41
- - [7.2. Client](#72-client)
42
- - [7.3. Server - ES5](#73-server---es5)
43
- - [7.3.1. Velocity](#731-velocity)
24
+ - [3. Migrering 0.x.x -> 1.x.x](#3-migrering-0xx---1xx)
25
+ - [4. Config](#4-config)
26
+ - [4.1. Konfigurationsfiler](#41-konfigurationsfiler)
27
+ - [4.2. Importera config](#42-importera-config)
28
+ - [4.3. ESLint ignore](#43-eslint-ignore)
29
+ - [5. Editors](#5-editors)
30
+ - [5.1. VS Code](#51-vs-code)
31
+ - [5.1.1. End of line](#511-end-of-line)
32
+ - [5.1.2. Autofix](#512-autofix)
33
+ - [5.1.3. Max length](#513-max-length)
34
+ - [5.1.4. Velocity](#514-velocity)
35
+ - [5.1.5. Vue](#515-vue)
36
+ - [5.1.6 Global konfig i underkatalog](#516-global-konfig-i-underkatalog)
37
+ - [5.1.7. Komplett config](#517-komplett-config)
38
+ - [6. CLI](#6-cli)
39
+ - [7. Git](#7-git)
40
+ - [8. Undantag](#8-undantag)
41
+ - [8.1. Server - ES2015+](#81-server---es2015)
42
+ - [8.2. Client](#82-client)
43
+ - [8.3. Server - ES5](#83-server---es5)
44
+ - [8.3.1. Velocity](#831-velocity)
44
45
 
45
46
  <!-- /TOC -->
46
47
 
@@ -49,14 +50,17 @@ https://eslint.org/docs/rules/
49
50
  Installera konfigurationen och `eslint` i ditt projekt genom att köra:
50
51
  `yarn add eslint @soleil-se/eslint-config-sitevision --dev`
51
52
 
52
- ## 3. Config
53
+ ## 3. Migrering 0.x.x -> 1.x.x
54
+
55
+ Se till att version 6 eller senare av ESLint är intstallerat i projektet.
56
+
57
+ ## 4. Config
53
58
  ESLint läster främst från `.eslintrc` filer i projektet.
54
59
  https://eslint.org/docs/user-guide/configuring#using-configuration-files-1
55
60
 
56
- ### 3.1 Konfigurationsfiler
61
+ ### 4.1. Konfigurationsfiler
57
62
 
58
- Man behöver skapa upp `.eslintrc` filer i sitt projekt.
59
- [yeoman-generatorn](https://github.com/soleilit/generator-sitevision) kan göra detta automatiskt med kommandot `yo @soleil-se/sitevision:eslint`
63
+ Man behöver skapa upp `.eslintrc` filer i sitt projekt. Dessa skapas automatiskt om du generar ditt projekt med [yeoman-generatorn](https://github.com/soleilit/generator-sitevision)
60
64
 
61
65
  Ett projekt som kör `@soleil-se/sv-gulp-build@^3.0.0` och inläsning global config.
62
66
  ```
@@ -164,7 +168,7 @@ Ett projekt som kör `@soleil-se/sv-gulp-build@^2.0.0`
164
168
  +---- .eslintrc (@soleil-se/eslint-config-sitevision/client)
165
169
  ```
166
170
 
167
- ### 3.2. Importera config
171
+ ### 4.2. Importera config
168
172
 
169
173
  Global konfig om man kör `@soleil-se/sv-gulp-build@^3.0.0`
170
174
  ```json
@@ -195,15 +199,24 @@ I server context:
195
199
  }
196
200
  ```
197
201
 
198
- ## 3. Editors
202
+ ### 4.3. ESLint ignore
203
+ Lägg med en `.eslintignore` fil i roten av projektet för att slå av linting av filer i `node_modules`, `dist` och velocityfiler.
204
+ ```
205
+ dist
206
+ node_nodules
207
+ **/node_nodules
208
+ **/*.vm
209
+ ```
210
+
211
+ ## 5. Editors
199
212
  Lättaste sättet att komma igång med ESLint är att installera det som extension i din editor.
200
213
 
201
- ### 3.1. VS Code
214
+ ### 5.1. VS Code
202
215
 
203
216
  Installera [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) till VS Code.
204
217
  Byt package manager till `yarn` i settings för eslint.
205
218
 
206
- #### 3.3.1. End of line
219
+ #### 5.1.1. End of line
207
220
  Airbnb använder sig av LF för EOL. Ställs in under [settings](https://code.visualstudio.com/docs/getstarted/settings) i VS Code.
208
221
  Ändra `\r\n` till `\n`.
209
222
  ```json
@@ -212,7 +225,7 @@ Airbnb använder sig av LF för EOL. Ställs in under [settings](https://code.vi
212
225
  }
213
226
  ```
214
227
 
215
- #### 3.3.2. Autofix
228
+ #### 5.1.2. Autofix
216
229
  Man kan ställa in så enklare fel åtgärdas automatiskt under [settings](https://code.visualstudio.com/docs/getstarted/settings) i VS Code.
217
230
  Se till att stänga av VS Codes inbyggda automatiska formatering.
218
231
 
@@ -223,7 +236,7 @@ Se till att stänga av VS Codes inbyggda automatiska formatering.
223
236
  }
224
237
  ```
225
238
 
226
- #### 3.3.3. Max length
239
+ #### 5.1.3. Max length
227
240
  Airbnb föresrpåkar en maxlängd på 100 tecken på en rad.
228
241
  Man kan ställa så man visar en linje i VS Code för att visualisera detta. Görs i [settings](https://code.visualstudio.com/docs/getstarted/settings).
229
242
 
@@ -250,7 +263,7 @@ Eller om man bara vill visa för JavaScript och Vue:
250
263
  }
251
264
  }
252
265
  ```
253
- #### 3.3.4. Velocity
266
+ #### 5.1.4. Velocity
254
267
  För att få stöd för skripttaggar i Velocity behöver man lägga in följande i [settings](https://code.visualstudio.com/docs/getstarted/settings).
255
268
  ```json
256
269
  "eslint.validate": [
@@ -262,7 +275,7 @@ För att få stöd för skripttaggar i Velocity behöver man lägga in följande
262
275
  }
263
276
  ]
264
277
  ```
265
- #### 3.3.5. Vue
278
+ #### 5.1.5. Vue
266
279
  För att få stöd för Vue behöver man lägga in följande i [settings](https://code.visualstudio.com/docs/getstarted/settings).
267
280
  ```json
268
281
  "eslint.validate": [
@@ -274,7 +287,7 @@ För att få stöd för Vue behöver man lägga in följande i [settings](https:
274
287
  }
275
288
  ]
276
289
  ```
277
- #### 3.3.6 Global konfig i underkatalog
290
+ #### 5.1.6 Global konfig i underkatalog
278
291
  Om man vill köra ESLint i en underkatalog som kör `@soleil-se/sv-gulp-build^3.0.0` behöver man lägga till denna som `workingDirectory` i ESLint tilläggets inställningar.
279
292
  Läs mer här: https://github.com/microsoft/vscode-eslint#settings-options
280
293
 
@@ -283,7 +296,7 @@ Exempelvis om det ligger i mappen `@next`:
283
296
  "eslint.workingDirectories": [".", { "directory": "./@next", "changeProcessCWD": true }],
284
297
  ```
285
298
 
286
- #### 3.3.7. Komplett config
299
+ #### 5.1.7. Komplett config
287
300
  ```json
288
301
  {
289
302
  "files.eol": "\n",
@@ -312,11 +325,11 @@ Exempelvis om det ligger i mappen `@next`:
312
325
  }
313
326
  ```
314
327
 
315
- ## 4. CLI
328
+ ## 6. CLI
316
329
  Om man vill köra ESLint i sin teminal.
317
330
  https://eslint.org/docs/user-guide/command-line-interface
318
331
 
319
- ## 5. Git
332
+ ## 7. Git
320
333
  Om man har problem med linebreaks i git kan man behöva göra följande:
321
334
  1. Pusha upp / stasha alla förändringar.
322
335
  2. Skapa en fil i roten av projektet med namnet `.gitattributes`.
@@ -328,22 +341,18 @@ Om man har problem med linebreaks i git kan man behöva göra följande:
328
341
  Mer info:
329
342
  https://stackoverflow.com/questions/9976986/force-lf-eol-in-git-repo-and-working-copy/34810209#34810209
330
343
 
331
- ## 6. Byggmiljö
332
-
333
- Om tid och intresse finns kan vi bygga in stöd för ESLint i [sv_gulp_build](https://github.com/soleilit/sv_gulp_build)
334
-
335
- ## 7. Undantag
344
+ ## 8. Undantag
336
345
 
337
- ### 7.1. Server - ES2015+
346
+ ### 8.1. Server - ES2015+
338
347
  `import/no-unresolved` - För att kunna importera SiteVisions API:er utan fel.
339
348
  `func-names` - Borde inte vara en varning, Airbnb tillåter anonyma funktioner.
340
349
 
341
- ### 7.2. Client
350
+ ### 8.2. Client
342
351
  `no-param-reassign` - Undantag för `state` i Vuex [mutations](https://vuex.vuejs.org/en/mutations.html).
343
352
  `vue/max-attributes-per-line` - Undantag för `allowFirstLine`, blev svårläst när det enforcas på element med korta namn (`<p> <a>` osv...)
344
353
  `vue/component-name-in-template-casing` - Enforca PascalCase i Vue komponenter.
345
354
 
346
- ### 7.3. Server - ES5
355
+ ### 8.3. Server - ES5
347
356
  `no-unused-vars` - Se till att visa vilka variabler som används i Velocity med `/* exported var1 var2 */` i toppen av filen.
348
357
  `no-undef` - Om en variabel är global, definera det med `/* global var1 var2 */` i toppen av filen.
349
358
  `vars-on-top` - Avslaget, blir helt crazy annars - Linh.
@@ -352,5 +361,5 @@ Om tid och intresse finns kan vi bygga in stöd för ESLint i [sv_gulp_build](ht
352
361
  `import/no-unresolved` - För att kunna importera SiteVisions API:er utan fel.
353
362
  `global-require` - För att kunna skriva `require` innanför IIFE i `src/index.js` i en Webapp.
354
363
 
355
- #### 7.3.1. Velocity
364
+ #### 8.3.1. Velocity
356
365
  `no-template-curly-in-string` - Avslaget, Velocity variabler ser ut som template variabler i ES6.
package/client.js CHANGED
@@ -11,7 +11,7 @@ module.exports = {
11
11
  ignorePropertyModificationsFor: ['state'],
12
12
  }],
13
13
  'vue/max-attributes-per-line': ['error', {
14
- singleline: 1,
14
+ singleline: 3,
15
15
  multiline: {
16
16
  max: 1,
17
17
  allowFirstLine: true,
package/global.js CHANGED
@@ -1,114 +1,114 @@
1
- module.exports = {
2
- extends: ['airbnb-base', 'plugin:vue/recommended'],
3
- plugins: ['vue', 'html'],
4
- overrides: [{
5
- /*
6
- * Configuration for server code.
7
- */
8
- files: [
9
- 'server_src/api/**/*.js',
10
- 'server_src/scripts/**/*.js',
11
- 'server_src/restapps/**/*.js',
12
- 'server_src/webapps/api/**/*.js',
13
- 'server_src/webapps/**/app_src/server/**/*.js',
14
- 'server_src/webapps/**/app_src/config/index.js',
15
- 'server_src/webapps/**/app_src/config/server/**/*.js',
16
- ],
17
- env: {
18
- amd: true,
19
- nashorn: true,
20
- node: false,
21
- commonjs: false,
22
- },
23
- globals: {
24
- scriptVariables: false,
25
- Packages: false,
26
- request: false,
27
- print: false,
28
- out: false,
29
- },
30
- rules: {
31
- 'import/no-unresolved': 0,
32
- 'func-names': 0,
33
- },
34
- settings: {
35
- 'import/resolver': {
36
- alias: {
37
- map: [
38
- ['#api', './server_src/api'],
39
- ['#api/scripts', './server_src/scripts/api'],
40
- ['#api/webapps', './server_src/webapps/api'],
41
- ['#api/restapps', './server_src/restapps/api'],
42
- ],
43
- extensions: ['.js', '.json'],
44
- },
45
- },
46
- },
47
- },
48
- {
49
- /*
50
- * Configuration for JavaScript in Velocity templates.
51
- */
52
- files: ['server_src/scripts/**/*.vm'],
53
- env: {
54
- browser: true,
55
- jquery: true,
56
- },
57
- globals: {
58
- $svjq: false,
59
- Soleil: false,
60
- },
61
- rules: {
62
- 'vars-on-top': 0,
63
- 'func-names': 0,
64
- },
65
- },
66
- {
67
- /*
68
- * Configuration for client code.
69
- */
70
- files: [
71
- '*.vue',
72
- 'client_src/js/**/*.js',
73
- 'server_src/webapps/**/app_src/client/**/*.js',
74
- 'server_src/webapps/**/app_src/config/config.js',
75
- 'server_src/webapps/**/app_src/config/client/**/*.js',
76
- ],
77
- env: {
78
- browser: true,
79
- jquery: true,
80
- },
81
- rules: {
82
- 'no-param-reassign': ['error', {
83
- props: true,
84
- ignorePropertyModificationsFor: ['state'],
85
- }],
86
- 'vue/max-attributes-per-line': ['error', {
87
- singleline: 1,
88
- multiline: {
89
- max: 1,
90
- allowFirstLine: true,
91
- },
92
- }],
93
- 'vue/component-name-in-template-casing': ['error', 'PascalCase', {
94
- registeredComponentsOnly: true,
95
- ignores: [],
96
- }],
97
- },
98
- settings: {
99
- 'import/resolver': {
100
- alias: {
101
- map: [
102
- ['#js', './client_src/js'],
103
- ['#api', './client_src/js/api'],
104
- ['#vue', './client_src/js/vue'],
105
- ],
106
- extensions: ['.js', '.json', '.vue'],
107
- },
108
- },
109
- },
110
- }],
111
- settings: {
112
- 'html/html-extensions': ['.html', '.vm'],
113
- },
114
- };
1
+ module.exports = {
2
+ extends: ['airbnb-base', 'plugin:vue/recommended'],
3
+ plugins: ['vue', 'html'],
4
+ overrides: [{
5
+ /*
6
+ * Configuration for server code.
7
+ */
8
+ files: [
9
+ 'server_src/api/**/*.js',
10
+ 'server_src/scripts/**/*.js',
11
+ 'server_src/restapps/**/*.js',
12
+ 'server_src/webapps/api/**/*.js',
13
+ 'server_src/webapps/**/app_src/server/**/*.js',
14
+ 'server_src/webapps/**/app_src/config/index.js',
15
+ 'server_src/webapps/**/app_src/config/server/**/*.js',
16
+ ],
17
+ env: {
18
+ amd: true,
19
+ nashorn: true,
20
+ node: false,
21
+ commonjs: false,
22
+ },
23
+ globals: {
24
+ scriptVariables: false,
25
+ Packages: false,
26
+ request: false,
27
+ print: false,
28
+ out: false,
29
+ },
30
+ rules: {
31
+ 'import/no-unresolved': 0,
32
+ 'func-names': 0,
33
+ },
34
+ settings: {
35
+ 'import/resolver': {
36
+ alias: {
37
+ map: [
38
+ ['#api', './server_src/api'],
39
+ ['#api/scripts', './server_src/scripts/api'],
40
+ ['#api/webapps', './server_src/webapps/api'],
41
+ ['#api/restapps', './server_src/restapps/api'],
42
+ ],
43
+ extensions: ['.js', '.json'],
44
+ },
45
+ },
46
+ },
47
+ },
48
+ {
49
+ /*
50
+ * Configuration for JavaScript in Velocity templates.
51
+ */
52
+ files: ['server_src/scripts/**/*.vm'],
53
+ env: {
54
+ browser: true,
55
+ jquery: true,
56
+ },
57
+ globals: {
58
+ $svjq: false,
59
+ Soleil: false,
60
+ },
61
+ rules: {
62
+ 'vars-on-top': 0,
63
+ 'func-names': 0,
64
+ },
65
+ },
66
+ {
67
+ /*
68
+ * Configuration for client code.
69
+ */
70
+ files: [
71
+ '*.vue',
72
+ 'client_src/js/**/*.js',
73
+ 'server_src/webapps/**/app_src/client/**/*.js',
74
+ 'server_src/webapps/**/app_src/config/config.js',
75
+ 'server_src/webapps/**/app_src/config/client/**/*.js',
76
+ ],
77
+ env: {
78
+ browser: true,
79
+ jquery: true,
80
+ },
81
+ rules: {
82
+ 'no-param-reassign': ['error', {
83
+ props: true,
84
+ ignorePropertyModificationsFor: ['state'],
85
+ }],
86
+ 'vue/max-attributes-per-line': ['error', {
87
+ singleline: 3,
88
+ multiline: {
89
+ max: 1,
90
+ allowFirstLine: true,
91
+ },
92
+ }],
93
+ 'vue/component-name-in-template-casing': ['error', 'PascalCase', {
94
+ registeredComponentsOnly: true,
95
+ ignores: [],
96
+ }],
97
+ },
98
+ settings: {
99
+ 'import/resolver': {
100
+ alias: {
101
+ map: [
102
+ ['#js', './client_src/js'],
103
+ ['#api', './client_src/js/api'],
104
+ ['#vue', './client_src/js/vue'],
105
+ ],
106
+ extensions: ['.js', '.json', '.vue'],
107
+ },
108
+ },
109
+ },
110
+ }],
111
+ settings: {
112
+ 'html/html-extensions': ['.html', '.vm'],
113
+ },
114
+ };
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@soleil-se/eslint-config",
3
- "version": "0.3.2",
3
+ "version": "1.0.0",
4
4
  "description": "Settings for ESLint in a SiteVision project",
5
5
  "author": "Soleil AB",
6
6
  "license": "UNLICENSED",
7
7
  "private": false,
8
8
  "homepage": "https://github.com/soleilit/eslint-config#readme",
9
9
  "dependencies": {
10
- "eslint": "^5.14.1",
11
- "eslint-config-airbnb-base": "^13.1.0",
10
+ "eslint": "^6.8.0",
11
+ "eslint-config-airbnb-base": "^14.0.0",
12
12
  "eslint-import-resolver-alias": "^1.1.2",
13
- "eslint-plugin-html": "^5.0.3",
14
- "eslint-plugin-import": "^2.16.0",
15
- "eslint-plugin-vue": "^5.2.2"
13
+ "eslint-plugin-html": "^6.0.0",
14
+ "eslint-plugin-import": "^2.20.0",
15
+ "eslint-plugin-vue": "^6.1.2"
16
16
  },
17
17
  "devDependencies": {
18
- "fs-extra": "^7.0.1"
18
+ "fs-extra": "^8.1.0"
19
19
  },
20
20
  "scripts": {
21
21
  "publish-scope": "node ./publish"
package/server-es6.js CHANGED
@@ -1,40 +1,40 @@
1
- module.exports = {
2
- extends: 'airbnb-base',
3
- env: {
4
- amd: true,
5
- nashorn: true,
6
- node: false,
7
- commonjs: false,
8
- },
9
- globals: {
10
- scriptVariables: false,
11
- Packages: false,
12
- request: false,
13
- svimport: false,
14
- solimport: false,
15
- print: false,
16
- out: false,
17
- Api: true,
18
- },
19
- rules: {
20
- 'import/no-unresolved': 0,
21
- 'vars-on-top': 0,
22
- 'no-param-reassign': ['error', {
23
- props: true,
24
- ignorePropertyModificationsFor: ['data'],
25
- }],
26
- },
27
- settings: {
28
- 'import/resolver': {
29
- alias: {
30
- map: [
31
- ['#api', './server_src/api'],
32
- ['#api/scripts', './server_src/scripts/api'],
33
- ['#api/webapps', './server_src/webapps/api'],
34
- ['#api/restapps', './server_src/restapps/api'],
35
- ],
36
- extensions: ['.js', '.json', '.vue'],
37
- },
38
- },
39
- },
40
- };
1
+ module.exports = {
2
+ extends: 'airbnb-base',
3
+ env: {
4
+ amd: true,
5
+ nashorn: true,
6
+ node: false,
7
+ commonjs: false,
8
+ },
9
+ globals: {
10
+ scriptVariables: false,
11
+ Packages: false,
12
+ request: false,
13
+ svimport: false,
14
+ solimport: false,
15
+ print: false,
16
+ out: false,
17
+ Api: true,
18
+ },
19
+ rules: {
20
+ 'import/no-unresolved': 0,
21
+ 'vars-on-top': 0,
22
+ 'no-param-reassign': ['error', {
23
+ props: true,
24
+ ignorePropertyModificationsFor: ['data'],
25
+ }],
26
+ },
27
+ settings: {
28
+ 'import/resolver': {
29
+ alias: {
30
+ map: [
31
+ ['#api', './server_src/api'],
32
+ ['#api/scripts', './server_src/scripts/api'],
33
+ ['#api/webapps', './server_src/webapps/api'],
34
+ ['#api/restapps', './server_src/restapps/api'],
35
+ ],
36
+ extensions: ['.js', '.json', '.vue'],
37
+ },
38
+ },
39
+ },
40
+ };
package/vue.js CHANGED
@@ -10,7 +10,7 @@ module.exports = {
10
10
  ignorePropertyModificationsFor: ['state'],
11
11
  }],
12
12
  'vue/max-attributes-per-line': ['error', {
13
- singleline: 1,
13
+ singleline: 3,
14
14
  multiline: {
15
15
  max: 1,
16
16
  allowFirstLine: true,