@soleil-se/eslint-config 3.1.0 → 4.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 CHANGED
@@ -5,78 +5,60 @@ Alla förändringar i detta repository antecknas här.
5
5
  Formatet baseras på [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  och projektet använder [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [3.1.0] - 2022-04-11
8
+ ## [4.0.0] - 2022-06-22
9
9
 
10
- ### Ändrat
10
+ - Förenkla genom att ta bort de de olika konfigurationerna och använd en och samma config för allt utom legacy kod.
11
+ - Modernisera legacy konfigurationen för att tillåta begränsad användning av ES2015+ som stöds av Rhino.
12
+ - Använd `eslint-config-prettier` i Svelte komponenter för att undvika krockar med ESLint.
13
+ - Ta bort stöd för Vue.
11
14
 
12
- - Tillåt användning av `console.error()` - för använding i exempelvis try catch.
15
+ ## [3.1.0] - 2022-04-11
13
16
 
14
- ## [3.0.1] - 2022-02-07
17
+ - Tillåt användning av `console.error()` - för exempelvis try catch.
15
18
 
16
- ### Ändrat
19
+ ## [3.0.1] - 2022-02-07
17
20
 
18
21
  - Ignorera `import/no-unresolved` för importer som börjar med `@sitevision/api/server`,
19
22
  `@sitevision/api/common` och `@sitevision/api/client` då alla API:er inte finns dokumenterade.
20
23
 
21
24
  ## [3.0.0] - 2022-02-07
22
25
 
23
- ### Ändrat
24
-
25
26
  - Tillåt enbart importer av Sitevisions API:er via `@sitevision/api`.
26
27
  - Uppdaterat sökvägarna i den globala och webapp configen för att stödja WebApps 2 strukturen.
27
28
  - Uppdaterat `peerDependencies` till senaste major versionerna.
28
29
 
29
30
  ## [2.4.5] - 2021-11-04
30
31
 
31
- ### Fixat
32
-
33
32
  - Sätt `ecmaVersion` till 2021 i client kontfigurationen om Vue används.
34
33
 
35
34
  ## [2.4.4] - 2021-09-09
36
35
 
37
- ### Fixat
38
-
39
36
  - Lägg till `options` i `svelteSortOrder`.
40
37
 
41
38
  ## [2.4.3] - 2021-08-27
42
39
 
43
- ### Fixat
44
-
45
40
  - Felstavning i regeln `no-return-assign` i Svelte-filer.
46
41
 
47
42
  ## [2.4.2] - 2021-08-17
48
43
 
49
- ### Fixat
50
-
51
44
  - Om Vue används i projektet sätt `ecmaVersion` till 2021 istället då pluginet använder Espree vilket inte klarar av samma versionsnamn som ESLint.
52
45
 
53
46
  ## [2.4.1] - 2021-08-17
54
47
 
55
- ### Ändrat
56
-
57
48
  - Sätt `ecmaVersion` till `latest` för att slippa uppdatera version varje år.
58
49
 
59
50
  ## [2.4.0] - 2021-03-24
60
51
 
61
- ### Nytt
62
-
63
52
  - Meddelande av deprekering för konfigurationerna `@soleil/eslint-config-sitevision/universal` och `@soleil/eslint-config-sitevision/server`
64
53
  - Nya konfigurationer med tydligare namn: `@soleil/eslint-config-sitevision/webapp` och `@soleil/eslint-config-sitevision/server-legacy`
65
-
66
- ### Ändrat
67
-
68
54
  - Tillåt fler properties per rad i ett objekt i `object-curly-newline`.
69
55
 
70
56
  ## [2.3.1] - 2021-02-24
71
57
 
72
- ### Ändrat
73
-
74
58
  - Dra tillbaka till `ecmaVersion` till 2020.
75
59
 
76
60
  ## [2.3.0] - 2021-02-24
77
61
 
78
- ### Ändrat
79
-
80
62
  - Fler regler överlappar när man skriver universell kod.
81
63
  - Slagit av `import/prefer-default-export`.
82
64
  - Slagit av `no-return-assig` i Svelte komponenter.
@@ -84,77 +66,52 @@ och projektet använder [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
84
66
 
85
67
  ## [2.2.1] - 2021-01-07
86
68
 
87
- ### Fixat
88
-
89
69
  - Tagit bort `babel-eslint` från dependencies.
90
70
 
91
71
  ## [2.2.0] - 2021-01-07
92
72
 
93
- ### Ändrat
94
-
95
73
  - Tagit bort `babel-eslint` och använder standardparsern med ES2020.
96
74
  - Förenklat `svelte.config.js`, oftast behövs inte plugin för globbing.
97
75
  - Lagt till paketet `cache` som undantag för SiteVision paket.
98
76
 
99
77
  ## [2.1.4] - 2020-10-26
100
78
 
101
- ### Fixat
102
-
103
79
  - Tagit bort felaktig konfiguration av `a11y-no-onchange`.
104
80
 
105
81
  ## [2.1.3] - 2020-10-21
106
82
 
107
- ### Ändrat
108
-
109
83
  - Lagt till `app_src/views/**/*.js` i server configen.
110
84
 
111
85
  ## [2.1.2] - 2020-10-06
112
86
 
113
- ### Fixat
114
-
115
- - Felaktiga `parserOptions` i `server-es6` configen.
87
+ - Åträgrdat felaktiga `parserOptions` i `server-es6` configen.
116
88
 
117
89
  ## [2.1.1] - 2020-10-06
118
90
 
119
- ### Ändrat
120
-
121
- - Ordning på config så de inställningar Svelte behöver för serversidan kommer med.
91
+ - Ändrat ordning på config så de inställningar Svelte behöver för serversidan kommer med.
122
92
 
123
93
  ## [2.1.0] - 2020-09-28
124
94
 
125
- ### Ändrat
126
-
127
95
  - Dependencies som behövs som standard ligger som peerDependencies
128
96
  - Dependencies för ramverksspecifika plugins behöver installeras utöver peerDependencies.
129
97
 
130
98
  ## [2.0.0] - 2020-09-28
131
99
 
132
- ### Ändrat
133
-
134
100
  - Stöd för Svelte.
135
101
  - Uppdaterad struktur.
136
102
  - Uppdatering till ESLint 7.
137
-
138
- ### Tagit bort
139
-
140
- - Konfigurationen för Vue, ligger nu i client.
103
+ - Tagit bort konfigurationen för Vue, ligger nu i client.
141
104
 
142
105
  ## [1.1.2] - 2020-02-05
143
106
 
144
- ### Ändrat
145
-
146
107
  - Ändrat regeln `import/extensions` så den ignorerar json-filer.
147
108
 
148
109
  ## [1.1.1] - 2020-01-27
149
110
 
150
- ### Ändrat
151
-
152
111
  - Ändrat regeln `import/extensions` så den ignorerar vue-filer.
153
112
 
154
113
  ## [1.1.0] - 2020-01-21
155
114
 
156
- ### Ändrat
157
-
158
115
  - Ändrat regeln `import/extensions` så den ignorerar paket, löser problem med import via alias.
159
116
 
160
117
  ## [1.0.0] - 2020-01-13
@@ -165,24 +122,16 @@ och projektet använder [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
165
122
 
166
123
  ## [0.3.3] - 2019-12-06
167
124
 
168
- ### Ändrat
169
-
170
125
  - Det får nu vara max 3 attribut per rad i Vue (`vue/max-attributes-per-line`).
171
126
 
172
127
  ## [0.3.2] - 2019-06-03
173
128
 
174
- ### Fixat
175
-
176
129
  - Lagt till `server_src/api` i server på den globala configen.
177
130
 
178
131
  ## [0.3.1] - 2019-05-20
179
132
 
180
- ### Ändrat
181
-
182
133
  - Slagit av `global-require` för att kunna skriva `require` innanför IIFE i `src/index.js` i en WebApp.
183
134
 
184
135
  ## [0.3.0] - 2019-05-20
185
136
 
186
- ### Nytt
187
-
188
137
  - 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`.
package/LICENSE.md CHANGED
@@ -1 +1 @@
1
- (c) Copyright 2020 Soleil AB, all rights reserved.
1
+ (c) Copyright 2022 Soleil AB, all rights reserved.
package/README.md CHANGED
@@ -1,77 +1,58 @@
1
1
 
2
- # `@soleil-se/eslint-config-sitevision@^3.0.0`
2
+ # `@soleil-se/eslint-config-sitevision@^5.0.0`
3
3
 
4
- ESLint configs anpassade för SiteVision som bygger på Airbnbs Javascript styleguide.
4
+ ESLint konfiguration för Sitevision projekt som bygger på Airbnbs JavaScript styleguide.
5
5
 
6
- **Klient & Server (ES2015+)**
6
+ **ES2015+**
7
7
  <https://github.com/airbnb/javascript>
8
8
 
9
- **Server (ES5)**
9
+ **Legacy (ES5)**
10
10
  <https://github.com/airbnb/javascript/tree/es5-deprecated/es5>
11
11
 
12
- Om man stöter på ett fel man inte förstår kan man kolla i styleguiden eller söka på eslints hemsida.
12
+ Om man stöter på ett fel man inte förstår kan man kolla i styleguiden eller söka på ESLints hemsida.
13
13
  <https://eslint.org/docs/rules/>
14
14
 
15
- ## Innehållsförteckning
16
-
17
- <!-- TOC depthFrom:2 updateOnSave:true -->
18
-
19
- - [Innehållsförteckning](#innehållsförteckning)
20
- - [Installera](#installera)
21
- - [Svelte](#svelte)
22
- - [Vue](#vue)
23
- - [Uppgradera 2.x.x -> 3.x.x](#uppgradera-2xx---3xx)
24
- - [Uppgradera 1.x.x -> 2.x.x](#uppgradera-1xx---2xx)
25
- - [Config](#config)
26
- - [Struktur](#struktur)
27
- - [Importera config](#importera-config)
28
- - [Global](#global)
29
- - [WebApp](#webapp)
30
- - [Client](#client)
31
- - [Server](#server)
32
- - [ESLint ignore](#eslint-ignore)
33
- - [Editors](#editors)
34
- - [VS Code](#vs-code)
35
- - [End of line](#end-of-line)
36
- - [Indentation](#indentation)
37
- - [Autofix](#autofix)
38
- - [Max length](#max-length)
39
- - [Velocity](#velocity)
40
- - [Svelte](#svelte-1)
41
- - [Vue](#vue-1)
42
- - [Global konfig i underkatalog](#global-konfig-i-underkatalog)
43
- - [Komplett config](#komplett-config)
44
- - [CLI](#cli)
45
- - [Svelte](#svelte-2)
46
- - [Kodformatering](#kodformatering)
47
- - [Preprocessing](#preprocessing)
48
- - [Git](#git)
49
-
50
- <!-- /TOC -->
15
+
51
16
 
52
17
  ## Installera
53
18
 
54
- Installera konfigurationen, eslint och de plugins som behövs plugins i ditt projekt genom att köra:
55
- `yarn add @soleil-se/eslint-config-sitevision eslint@^8.0.0 eslint-config-airbnb-base@^15.0.0 eslint-plugin-import@^2.0.0 --dev`
19
+ Installera konfigurationen, ESLint och de plugins som behövs plugins i ditt projekt genom att köra:
56
20
 
57
- ### Svelte
21
+ ```bash
22
+ yarn add @soleil-se/eslint-config-sitevision eslint@^8.0.0 eslint-config-airbnb-base@^15.0.0 eslint-plugin-import@^2.0.0 --dev
23
+ ```
58
24
 
59
25
  Om Svelte används i projektet:
60
- `yarn add eslint-plugin-svelte3@^3.0.0 svelte@^3.0.0 svelte-preprocess@^4.0.0 --dev`
61
26
 
62
- ### Vue
27
+ ```bash
28
+ yarn add eslint-plugin-svelte3@^3.0.0 svelte@^3.0.0 svelte-preprocess@^4.0.0 eslint-config-prettier@^8.0.0 --dev
29
+ ```
30
+
31
+ ## Uppgradera
32
+
33
+ ### Version 3.x.x > 4.x.x
63
34
 
64
- Om Vue används i projektet:
65
- `yarn add eslint-plugin-vue@^7.0.0 vue-eslint-parser@^7.0.0 --dev`
35
+ - Om Vue används i projektet **stanna** på version 3, stödet för Vue plockas bort i denna version.
36
+ - Uppgradera `@soleil-se/eslint-config-sitevision` till version 4 med `yarn upgrade @soleil-se/eslint-config-sitevision@latest`.
37
+ - Om Svelte används i projektet installera `eslint-config-prettier` med `yarn add eslint-config-prettier --dev`.
38
+ - Byt ut alla importer av konfigurationer:
39
+ - `@soleil-se/eslint-config-sitevision/global` > `@soleil-se/eslint-config-sitevision`
40
+ - `@soleil-se/eslint-config-sitevision/webapp` > `@soleil-se/eslint-config-sitevision`
41
+ - `@soleil-se/eslint-config-sitevision/client` > `@soleil-se/eslint-config-sitevision`
42
+ - `@soleil-se/eslint-config-sitevision/server-es6` > `@soleil-se/eslint-config-sitevision`
43
+ - `@soleil-se/eslint-config-sitevision/universal` > `@soleil-se/eslint-config-sitevision`
44
+ - Byt ut alla importer av legacy konfigurationer:
45
+ - `@soleil-se/eslint-config-sitevision/server-legacy` > `@soleil-se/eslint-config-sitevision/legacy`
46
+ - `@soleil-se/eslint-config-sitevision/server` > `@soleil-se/eslint-config-sitevision/legacy`
66
47
 
67
- ## Uppgradera 2.x.x -> 3.x.x
48
+ ### Version 2.x.x > 3.x.x
68
49
 
69
50
  - Uppgradera `@soleil-se/eslint-config-sitevision` till version 3.
70
51
  - Uppgradera `eslint` till version 8.
71
52
  - Uppgradera `eslint-config-airbnb-base` till version 15.
72
53
  - Ändra importer till Sitevisions API:er till `@sitevision/api/(server|common|client)/NamnPåAPI`.
73
54
 
74
- ## Uppgradera 1.x.x -> 2.x.x
55
+ ### VErsion 1.x.x > 2.x.x
75
56
 
76
57
  - Uppgradera `eslint` till version 7.
77
58
  - Installera alla dependencies enligt installationssteget.
@@ -79,82 +60,35 @@ Om Vue används i projektet:
79
60
 
80
61
  ## Config
81
62
 
82
- ESLint läster främst från `.eslintrc.js` filer i projektet.
63
+ ESLint läster främst från `.eslintrc.js` filer i projektet.
83
64
  <https://eslint.org/docs/user-guide/configuring#using-configuration-files-1>
84
65
 
85
- ### Struktur
86
-
87
- [Här finns exempel på struktur](./docs/structure.md).
88
-
89
66
  ### Importera config
90
67
 
91
- ### Global
92
-
93
- Global konfiguration som läses in i rotkatalogen för projektet.
94
- Kan användas om projektet följer standardstrukturen.
95
-
96
- ```js
97
- module.exports = {
98
- extends: '@soleil-se/eslint-config-sitevision/global'
99
- }
100
- ```
101
-
102
- ### WebApp
103
-
104
- Konfiguration om man har en självstående WebApp.
105
- Läses in i rotkatalogen för appen.
106
-
107
68
  ```js
108
69
  module.exports = {
109
- extends: '@soleil-se/eslint-config-sitevision/webapp',
110
- root: true,
111
- }
112
- ```
113
-
114
- ### Client
115
-
116
- Konfiguration för kod som ska köras på klientsidan (browsern).
117
-
118
- ```js
119
- module.exports = {
120
- extends: '@soleil-se/eslint-config-sitevision/client',
121
- root: true,
122
- }
123
- ```
124
-
125
- ### Server
126
-
127
- Konfiguration för kod som ska köras på serversidan (Sitevision).
128
-
129
- I kontext med stöd för ES6+.
130
- Till exempel serverkod som byggs ihop.
131
-
132
- ```js
133
- module.exports = {
134
- extends: '@soleil-se/eslint-config-sitevision/server-es6',
135
- root: true,
136
- }
70
+ extends: '@soleil-se/eslint-config-sitevision',
71
+ };
137
72
  ```
138
73
 
139
- I kontext med stöd för ES5.
140
- Till exempel serverkod som ska laddas upp som den är till Sitevision utan byggsteg.
74
+ Legacy config som används i en kontext med stöd för ES5 och delvis ES2015+.
75
+ Till exempel serverkod som ska laddas upp som den är till Sitevision utan kompilering.
141
76
 
142
77
  ```js
143
78
  module.exports = {
144
- extends: '@soleil-se/eslint-config-sitevision/server-legacy',
79
+ extends: '@soleil-se/eslint-config-sitevision/legacy',
145
80
  root: true,
146
- }
81
+ };
147
82
  ```
148
83
 
149
84
  ### ESLint ignore
150
85
 
151
- Lägg med en `.eslintignore` fil i roten av projektet för att slå av linting av filer i `node_modules`, `dist` och velocityfiler.
86
+ Lägg med en `.eslintignore` fil i roten av projektet för att slå av linting av filer i bland annat `node_modules` och `dist`.
152
87
 
153
88
  ```
154
89
  dist
155
90
  node_nodules
156
91
  **/node_nodules
157
- **/*.vm
158
92
  svelte.config
159
93
  ```
160
94
 
@@ -162,22 +96,15 @@ svelte.config
162
96
 
163
97
  Enklaste sättet att komma igång med ESLint är att installera det som extension i din editor.
164
98
 
165
- ### VS Code
166
-
167
- Installera [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) till VS Code.
168
- Byt package manager till `yarn` i settings för eslint.
99
+ ### Visual Studio Code
169
100
 
170
- ```json
171
- {
172
- "eslint.packageManager": "yarn"
173
- }
174
- ```
101
+ Installera [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) till Visual Studio Code.
175
102
 
176
103
  #### End of line
177
104
 
178
- Airbnb använder sig av LF för EOL. Ställs in under [settings](https://code.visualstudio.com/docs/getstarted/settings) i VS Code.
179
- Ändra `\r\n` till `\n`.
180
- Sen vill man även ha att en ny rad inkluderas i filerna.
105
+ Airbnb använder sig av LF för EOL. Ställs in under [settings](https://code.visualstudio.com/docs/getstarted/settings) i Visual Studio Code.
106
+ Ändra `\r\n` till `\n`.
107
+ Sen vill man även ha att en ny rad inkluderas i filerna.
181
108
 
182
109
  ```json
183
110
  {
@@ -199,7 +126,7 @@ Airbnb indenterar med två spaces.
199
126
 
200
127
  #### Autofix
201
128
 
202
- Man kan ställa in så enklare fel åtgärdas automatiskt under [settings](https://code.visualstudio.com/docs/getstarted/settings) i VS Code.
129
+ Man kan ställa in så enklare fel åtgärdas automatiskt under [settings](https://code.visualstudio.com/docs/getstarted/settings) i Visual Studio Code.
203
130
 
204
131
  ```json
205
132
  {
@@ -211,8 +138,8 @@ Man kan ställa in så enklare fel åtgärdas automatiskt under [settings](https
211
138
 
212
139
  #### Max length
213
140
 
214
- Airbnb föresrpåkar en maxlängd på 100 tecken på en rad.
215
- 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).
141
+ Airbnb föresrpåkar en maxlängd på 100 tecken på en rad.
142
+ Man kan ställa så man visar en linje i Visual Studio Code för att visualisera detta. Görs i [settings](https://code.visualstudio.com/docs/getstarted/settings).
216
143
 
217
144
  ```json
218
145
  {
@@ -222,68 +149,29 @@ Man kan ställa så man visar en linje i VS Code för att visualisera detta. Gö
222
149
  }
223
150
  ```
224
151
 
225
- Eller om man bara vill visa för JavaScript och Vue:
226
-
227
- ```json
228
- {
229
- "[javascript]": {
230
- "editor.rulers": [
231
- 100
232
- ]
233
- },
234
- "[vue]": {
235
- "editor.rulers": [
236
- 100
237
- ]
238
- }
239
- }
240
- ```
241
-
242
- #### Velocity
243
-
244
- 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).
245
-
246
- ```json
247
- "eslint.validate": [
248
- "javascript",
249
- "javascriptreact",
250
- "velocity"
251
- ]
252
- ```
253
-
254
152
  #### Svelte
255
153
 
256
154
  För att få stöd för Svelte behöver man lägga in följande i [settings](https://code.visualstudio.com/docs/getstarted/settings).
257
155
 
258
156
  ```json
259
- "eslint.validate": [
260
- "javascript",
261
- "javascriptreact",
262
- "svelte"
263
- ]
264
- ```
265
-
266
- #### Vue
267
-
268
- 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).
269
-
270
- ```json
271
- "eslint.validate": [
272
- "javascript",
273
- "javascriptreact",
274
- "vue"
275
- ]
157
+ {
158
+ "eslint.validate": [
159
+ "javascript",
160
+ "javascriptreact",
161
+ "svelte"
162
+ ]
163
+ }
276
164
  ```
277
165
 
278
- #### Global konfig i underkatalog
166
+ #### Konfig i underkatalog
279
167
 
280
- 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.
168
+ Om man vill köra ESLint i en underkatalog som kör `@soleil-se/sv-gulp-build^4.0.0` behöver man lägga till denna som `workingDirectory` i ESLint tilläggets inställningar.
281
169
  Läs mer här: <https://github.com/microsoft/vscode-eslint#settings-options>
282
170
 
283
- Exempelvis om det ligger i mappen `@next`:
171
+ Exempelvis om det ligger i mappen `next`:
284
172
 
285
173
  ```json
286
- "eslint.workingDirectories": [".", { "directory": "./@next", "changeProcessCWD": true }],
174
+ "eslint.workingDirectories": [".", { "directory": "./next", "changeProcessCWD": true }],
287
175
  ```
288
176
 
289
177
  #### Komplett config
@@ -306,10 +194,7 @@ Exempelvis om det ligger i mappen `@next`:
306
194
  "eslint.packageManager": "yarn",
307
195
  "eslint.validate": [
308
196
  "javascript",
309
- "javascriptreact",
310
- "vue",
311
- "html",
312
- "velocity",
197
+ "javascriptreact",
313
198
  "svelte",
314
199
  ],
315
200
  "[svelte]": {
@@ -320,12 +205,12 @@ Exempelvis om det ligger i mappen `@next`:
320
205
 
321
206
  ## CLI
322
207
 
323
- Om man vill köra ESLint i sin terminal.
208
+ Om man vill köra ESLint i sin terminal.
324
209
  <https://eslint.org/docs/user-guide/command-line-interface>
325
210
 
326
211
  ## Svelte
327
212
 
328
- Installera [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) tillägget till VS Code för att få korrekt highlighing osv.
213
+ Installera [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) tillägget till Visual Studio Code.
329
214
 
330
215
  ### Kodformatering
331
216
 
@@ -338,7 +223,7 @@ Skapa en fil som heter `.prettierrc.js` i roten av projektet.
338
223
  module.exports = require('@soleil-se/eslint-config-sitevision/svelte.prettier');
339
224
  ```
340
225
 
341
- För att formatera automatiskt behöver man lägga till följande i `settings.json` i VS Code.
226
+ För att formatera automatiskt behöver man lägga till följande i `settings.json` i Visual Studio Code.
342
227
 
343
228
  ```json
344
229
  {
@@ -360,42 +245,6 @@ Man kan även stänga av formateringen av skript genom att lägga till kommentar
360
245
  <p>{foo}</p>
361
246
  ```
362
247
 
363
- ### Preprocessing
364
-
365
- För att få korrekta felmeddelanden i SCSS och Less behöver man berätta för Svelte att man använder en preprocessor.
366
- Skapa en fil som heter `svelte.config.js` i roten av projektet.
367
-
368
- Om du använder SCSS i projektet:
369
-
370
- ```js
371
- /* eslint-disable import/no-extraneous-dependencies */
372
- const preprocess = require('svelte-preprocess');
373
-
374
- module.exports = {
375
- preprocess: preprocess({
376
- scss: { includePaths: [`${__dirname}/client_src/sass`, `${__dirname}/../../../../client_src/sass`] },
377
- postcss: false,
378
- }),
379
- };
380
- ```
381
-
382
- Om du använder Less i projektet:
383
-
384
- ```js
385
- /* eslint-disable import/no-extraneous-dependencies */
386
- const preprocess = require('svelte-preprocess');
387
-
388
- module.exports = {
389
- preprocess: preprocess({
390
- less: {
391
- paths: ['./client_src/less', '../../../../client_src/less'],
392
- },
393
- postcss: false,
394
- }),
395
- };
396
-
397
- ```
398
-
399
248
  ## Git
400
249
 
401
250
  Om man har problem med linebreaks i git kan man behöva göra följande:
@@ -407,5 +256,4 @@ Om man har problem med linebreaks i git kan man behöva göra följande:
407
256
  5. Kör: `git reset --hard`.
408
257
  6. Pusha upp filen.
409
258
 
410
- Mer info:
411
259
  <https://stackoverflow.com/questions/9976986/force-lf-eol-in-git-repo-and-working-copy/34810209#34810209>
@@ -1,26 +1,28 @@
1
+ const { hasSvelte, hasPrettier } = require('./utils/hasDependency');
2
+
1
3
  module.exports = {
4
+ extends: ['airbnb-base'],
5
+ plugins: hasSvelte ? ['svelte3'] : [],
6
+ parserOptions: {
7
+ ecmaVersion: 'latest',
8
+ sourceType: 'module',
9
+ },
2
10
  env: {
3
11
  browser: true,
4
12
  jquery: true,
5
- nashorn: true,
6
13
  },
7
14
  globals: {
8
- process: true,
9
- Packages: false,
15
+ process: 'readonly',
16
+ Packages: 'readonly',
10
17
  },
11
18
  rules: {
12
19
  'import/extensions': ['error', 'never', {
13
20
  ignorePackages: true,
14
21
  pattern: {
15
- vue: 'always',
16
22
  svelte: 'always',
17
23
  json: 'always',
18
24
  },
19
25
  }],
20
- 'no-param-reassign': ['error', {
21
- props: true,
22
- ignorePropertyModificationsFor: ['state'],
23
- }],
24
26
  'import/no-unresolved': [2, { ignore: ['#', '@sitevision/api/server', '@sitevision/api/common', '@sitevision/api/client'] }],
25
27
  'import/prefer-default-export': 0,
26
28
  'object-curly-newline': ['error', {
@@ -31,4 +33,23 @@ module.exports = {
31
33
  }],
32
34
  'no-console': [1, { allow: ['error'] }],
33
35
  },
36
+ overrides: [{
37
+ files: ['*.svelte'],
38
+ extends: hasPrettier ? ['prettier'] : [],
39
+ processor: 'svelte3/svelte3',
40
+ rules: {
41
+ 'import/first': 0,
42
+ 'import/no-mutable-exports': 0,
43
+ 'import/prefer-default-export': 0,
44
+ 'no-multiple-empty-lines': 0,
45
+ 'no-label-var': 0,
46
+ 'no-undef-init': 0,
47
+ 'no-return-assign': 0,
48
+ 'operator-linebreak': 'off',
49
+ 'object-curly-newline': 'off',
50
+ },
51
+ settings: {
52
+ 'svelte3/ignore-styles': () => true,
53
+ },
54
+ }],
34
55
  };
package/legacy.js ADDED
@@ -0,0 +1,38 @@
1
+ module.exports = {
2
+ extends: 'airbnb-base/legacy',
3
+ env: {
4
+ es6: true,
5
+ amd: true,
6
+ node: false,
7
+ commonjs: false,
8
+ },
9
+ parserOptions: {
10
+ ecmaVersion: 'latest',
11
+ },
12
+ globals: {
13
+ scriptVariables: 'readonly',
14
+ Packages: 'readonly',
15
+ request: 'readonly',
16
+ print: 'readonly',
17
+ out: 'readonly',
18
+ },
19
+ rules: {
20
+ 'vars-on-top': 0,
21
+ 'no-param-reassign': ['error', {
22
+ props: true,
23
+ ignorePropertyModificationsFor: ['data'],
24
+ }],
25
+ 'func-names': 0,
26
+ 'global-require': 0,
27
+ strict: 0,
28
+ 'no-redeclare': ['error', { builtinGlobals: false }],
29
+ 'comma-dangle': ['error', 'always-multiline'],
30
+ },
31
+ overrides: [{
32
+ files: ['.eslintrc.js'],
33
+ env: {
34
+ node: true,
35
+ commonjs: true,
36
+ },
37
+ }],
38
+ };
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@soleil-se/eslint-config",
3
- "version": "3.1.0",
4
- "description": "Settings for ESLint in a SiteVision project",
3
+ "version": "4.0.0",
4
+ "description": "ESLint konfiguration för Sitevision utveckling",
5
5
  "author": "Soleil AB",
6
6
  "license": "UNLICENSED",
7
7
  "private": false,
8
8
  "homepage": "https://docs.soleilit.se/03.packages/@soleil&@soleil-se/eslint-config",
9
9
  "devDependencies": {
10
- "eslint": "^8.8.0",
10
+ "eslint": "^8.13.0",
11
11
  "eslint-config-airbnb-base": "^15.0.0",
12
- "eslint-plugin-import": "^2.25.4",
13
- "eslint-plugin-svelte3": "^3.4.0",
14
- "eslint-plugin-vue": "^8.4.1",
15
- "svelte": "^3.46.4"
12
+ "eslint-config-prettier": "^8.5.0",
13
+ "eslint-plugin-import": "^2.26.0",
14
+ "eslint-plugin-svelte3": "^3.4.1",
15
+ "svelte": "^3.47.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "eslint": "^8.0.0",
@@ -6,5 +6,5 @@ module.exports = {
6
6
  svelteStrictMode: false,
7
7
  trailingComma: 'es5',
8
8
  svelteSortOrder: 'options-scripts-markup-styles',
9
- svelteBracketNewLine: true,
9
+ bracketSameLine: false,
10
10
  };
@@ -0,0 +1,15 @@
1
+ const isRequireable = (id) => {
2
+ try {
3
+ require.resolve(id, {
4
+ paths: [process.cwd()],
5
+ });
6
+ return true;
7
+ } catch (e) {
8
+ return false;
9
+ }
10
+ };
11
+
12
+ module.exports = {
13
+ hasSvelte: isRequireable('eslint-plugin-svelte3'),
14
+ hasPrettier: isRequireable('eslint-config-prettier'),
15
+ };
package/FAQ.md DELETED
@@ -1,21 +0,0 @@
1
- # FAQ
2
- <!-- TOC depthTo:2 -->
3
-
4
- - [Parsing error: Unexpected token](#Parsing-error:-Unexpected-token)
5
-
6
- <!-- /TOC -->
7
-
8
- ## Parsing error: Unexpected token
9
-
10
- ### Felmeddelandet
11
- ```sh
12
- 1:1 Parsing error: Unexpected token <
13
- ```
14
- ### Inträffar
15
- När man kör `yarn gulp` och försöker bygga en webbapp med Vue.
16
-
17
- ### Vad det betyder
18
- Eslint tasken klagar, förmodligen är den utdaterad och behöver uppdateras.
19
-
20
- ### Hur man kan lösa det
21
- Följ stegen för Vue här: https://github.com/soleilit/eslint-config-sitevision#2-installera
package/client.js DELETED
@@ -1,16 +0,0 @@
1
- const {
2
- getExtends, getPlugins, getOverrides, hasVue,
3
- } = require('./utils');
4
- const client = require('./shared/client');
5
-
6
- module.exports = {
7
- extends: getExtends(),
8
- plugins: getPlugins(),
9
- parserOptions: {
10
- // Vue plugin uses Espree for ECMA versions, 'latest' does not work.
11
- ecmaVersion: hasVue ? 2021 : 'latest',
12
- sourceType: 'module',
13
- },
14
- overrides: getOverrides(),
15
- ...client,
16
- };
package/docs/structure.md DELETED
@@ -1,115 +0,0 @@
1
- # Projectstruktur
2
-
3
- Här finns exempel var konfigurationsfilerna bör ligga.
4
-
5
- <!-- TOC -->
6
-
7
- - [Global](#global)
8
- - [WebApp](#webapp)
9
- - [Enskilda filer](#enskilda-filer)
10
-
11
- <!-- /TOC -->
12
-
13
- ## Global
14
-
15
- Ett projekt som kör `@soleil/sv-gulp-build@^3.0.0` eller `@soleil/sv-project-build` och inläsning global config.
16
-
17
- ```
18
- <sitevision_projekt>
19
- |
20
- +---- server_src
21
- | |
22
- | +---- snippets
23
- | |
24
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-legacy)
25
- |
26
- +---- .eslintrc.js (@soleil/eslint-config-sitevision/global)
27
-
28
- ```
29
-
30
- ## WebApp
31
-
32
- I en fristående WebApp.
33
-
34
- ```
35
- MyWebApp
36
- |
37
- +---- src
38
- |
39
- +---- .eslintrc.js (@soleil/eslint-config-sitevision/webapp)
40
-
41
- ```
42
-
43
- ## Enskilda filer
44
-
45
- Ett projekt som kör `@soleil/sv-gulp-build@^3.0.0` eller `@soleil/sv-project-build` och inläsning av enskilda config-filer.
46
-
47
- ```
48
- <sitevision_projekt>
49
- |
50
- +---- client_src
51
- | |
52
- | +---- js
53
- | |
54
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/client)
55
- |
56
- +---- server_src
57
- |
58
- +---- api
59
- | |
60
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-es6)
61
- |
62
- +---- restapps
63
- | |
64
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-es6)
65
- |
66
- +---- scripts
67
- | |
68
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-es6)
69
- |
70
- +---- snippets
71
- | |
72
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-legacy)
73
- |
74
- +---- webapps
75
- |
76
- +---- api
77
- | |
78
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-es6)
79
- |
80
- +---- apps
81
- |
82
- +---- App
83
- |
84
- +---- .eslintrc.js (@soleil/eslint-config-sitevision/webapp)
85
- ```
86
-
87
- Ett projekt som kör `@soleil/sv-gulp-build@^2.0.0`
88
-
89
- ```
90
- <sitevision_projekt>
91
- |
92
- +---- client_src
93
- | |
94
- | +---- js
95
- | |
96
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/client)
97
- |
98
- +---- server_src
99
- | |
100
- | +---- .eslintrc.js
101
- |
102
- +---- webapps_src
103
- |
104
- +---- apps
105
- |
106
- +---- App
107
- |
108
- +---- src
109
- | |
110
- | +---- .eslintrc.js (@soleil/eslint-config-sitevision/server-legacy)
111
- |
112
- +---- vue
113
- |
114
- +---- .eslintrc.js (@soleil/eslint-config-sitevision/client)
115
- ```
package/global.js DELETED
@@ -1,41 +0,0 @@
1
- const {
2
- getExtends, getPlugins, getOverrides, hasVue,
3
- } = require('./utils');
4
-
5
- const server = require('./shared/server');
6
- const client = require('./shared/client');
7
- const universal = require('./shared/universal');
8
-
9
- module.exports = {
10
- extends: getExtends(),
11
- plugins: getPlugins(),
12
- parserOptions: {
13
- // Vue plugin uses Espree for ECMA versions, 'latest' does not work.
14
- ecmaVersion: hasVue ? 2021 : 'latest',
15
- sourceType: 'module',
16
- },
17
- overrides: [
18
- {
19
- files: [
20
- '*.vue',
21
- 'client_src/js/**/*.js',
22
- ],
23
- ...client,
24
- },
25
- {
26
- files: [
27
- 'server_src/api/**/*.js',
28
- 'server_src/scripts/**/*.js',
29
- 'server_src/restapps/**/*.js',
30
- ],
31
- ...server,
32
- },
33
- {
34
- files: [
35
- '*.svelte',
36
- 'server_src/webapps/**/*.js',
37
- ],
38
- ...universal,
39
- },
40
- ].concat(getOverrides()),
41
- };
@@ -1,22 +0,0 @@
1
- module.exports = {
2
- files: ['*.svelte'],
3
- processor: 'svelte3/svelte3',
4
- rules: {
5
- 'import/first': 0,
6
- 'import/no-mutable-exports': 0,
7
- 'import/prefer-default-export': 0,
8
- 'no-multiple-empty-lines': 0,
9
- 'no-label-var': 0,
10
- 'no-undef-init': 0,
11
- 'no-return-assign': 0,
12
- 'operator-linebreak': 'off',
13
- 'object-curly-newline': 'off',
14
- },
15
- settings: {
16
- 'svelte3/ignore-styles': () => true,
17
- 'svelte3/ignore-warnings': ({ code }) => {
18
- if (code === 'a11y-no-onchange') return true;
19
- return false;
20
- },
21
- },
22
- };
package/overrides/vue.js DELETED
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- files: ['*.vue'],
3
- rules: {
4
- 'no-param-reassign': ['error', {
5
- props: true,
6
- ignorePropertyModificationsFor: ['state'],
7
- }],
8
- 'vue/max-attributes-per-line': ['error', {
9
- singleline: 3,
10
- multiline: {
11
- max: 1,
12
- allowFirstLine: true,
13
- },
14
- }],
15
- 'vue/component-name-in-template-casing': ['error', 'PascalCase', {
16
- registeredComponentsOnly: true,
17
- ignores: [],
18
- }],
19
- },
20
- };
package/server-es6.js DELETED
@@ -1,16 +0,0 @@
1
- const {
2
- getExtends, getPlugins, getOverrides, hasVue,
3
- } = require('./utils');
4
- const server = require('./shared/server');
5
-
6
- module.exports = {
7
- extends: getExtends(),
8
- parserOptions: {
9
- // Vue plugin uses Espree for ECMA versions, 'latest' does not work.
10
- ecmaVersion: hasVue ? 2021 : 'latest',
11
- sourceType: 'module',
12
- },
13
- plugins: getPlugins(),
14
- overrides: getOverrides(),
15
- ...server,
16
- };
package/server-legacy.js DELETED
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- extends: 'airbnb-base/legacy',
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
- print: false,
15
- out: false,
16
- Api: true,
17
- solimport: true,
18
- },
19
- rules: {
20
- 'vars-on-top': 0,
21
- 'no-param-reassign': ['error', {
22
- props: true,
23
- ignorePropertyModificationsFor: ['data'],
24
- }],
25
- 'func-names': 0,
26
- 'global-require': 0,
27
- strict: 0,
28
- },
29
- };
package/server.js DELETED
@@ -1,2 +0,0 @@
1
- console.warn('WARN: \'@soleil/eslint-config-sitevision/server\' is deprecated, please switch to \'@soleil/eslint-config-sitevision/server-legacy\'.');
2
- module.exports = require('./server-legacy');
package/shared/client.js DELETED
@@ -1,32 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- jquery: true,
5
- },
6
- globals: {
7
- process: true,
8
- },
9
- rules: {
10
- 'import/extensions': ['error', 'never', {
11
- ignorePackages: true,
12
- pattern: {
13
- vue: 'always',
14
- svelte: 'always',
15
- json: 'always',
16
- },
17
- }],
18
- 'no-param-reassign': ['error', {
19
- props: true,
20
- ignorePropertyModificationsFor: ['state'],
21
- }],
22
- 'import/no-unresolved': [2, { ignore: ['#', '@sitevision/api/common', '@sitevision/api/client'] }],
23
- 'import/prefer-default-export': 0,
24
- 'object-curly-newline': ['error', {
25
- ObjectExpression: { minProperties: 8, multiline: true, consistent: true },
26
- ObjectPattern: { minProperties: 8, multiline: true, consistent: true },
27
- ImportDeclaration: { minProperties: 8, multiline: true, consistent: true },
28
- ExportDeclaration: { minProperties: 8, multiline: true, consistent: true },
29
- }],
30
- 'no-console': [1, { allow: ['error'] }],
31
- },
32
- };
package/shared/server.js DELETED
@@ -1,34 +0,0 @@
1
- module.exports = {
2
- env: {
3
- amd: true,
4
- nashorn: true,
5
- node: false,
6
- commonjs: false,
7
- },
8
- globals: {
9
- scriptVariables: false,
10
- Packages: false,
11
- request: false,
12
- print: false,
13
- out: false,
14
- process: true,
15
- },
16
- rules: {
17
- 'func-names': 0,
18
- 'import/extensions': ['error', 'never', {
19
- ignorePackages: true,
20
- pattern: {
21
- json: 'always',
22
- },
23
- }],
24
- 'import/no-unresolved': [2, { ignore: ['#', '@sitevision/api/server', '@sitevision/api/common'] }],
25
- 'import/prefer-default-export': 0,
26
- 'object-curly-newline': ['error', {
27
- ObjectExpression: { minProperties: 8, multiline: true, consistent: true },
28
- ObjectPattern: { minProperties: 8, multiline: true, consistent: true },
29
- ImportDeclaration: { minProperties: 8, multiline: true, consistent: true },
30
- ExportDeclaration: { minProperties: 8, multiline: true, consistent: true },
31
- }],
32
- 'no-console': [1, { allow: ['error'] }],
33
- },
34
- };
package/svelte.config.js DELETED
@@ -1,14 +0,0 @@
1
- /* eslint-disable import/no-unresolved, import/no-extraneous-dependencies */
2
- const preprocess = require('svelte-preprocess');
3
-
4
- module.exports = {
5
- preprocess: preprocess({
6
- scss: {
7
- includePaths: [`${process.cwd()}/client_src/sass`],
8
- },
9
- less: {
10
- paths: ['./client_src/less'],
11
- },
12
- postcss: false,
13
- }),
14
- };
package/universal.js DELETED
@@ -1,2 +0,0 @@
1
- console.warn('WARN: \'@soleil/eslint-config-sitevision/universal\' is deprecated, please switch to \'@soleil/eslint-config-sitevision/webapp\'.');
2
- module.exports = require('./webapp');
package/utils/index.js DELETED
@@ -1,41 +0,0 @@
1
- const isRequireable = (id) => {
2
- try {
3
- require.resolve(id, {
4
- paths: [process.cwd()],
5
- });
6
- return true;
7
- } catch (e) {
8
- return false;
9
- }
10
- };
11
-
12
- const hasVue = isRequireable('eslint-plugin-vue');
13
- const hasSvelte = isRequireable('eslint-plugin-svelte3');
14
-
15
- const getExtends = () => {
16
- const extend = ['airbnb-base'];
17
- if (hasVue) extend.push('plugin:vue/recommended');
18
- return extend;
19
- };
20
-
21
- const getPlugins = () => {
22
- const plugins = [];
23
- if (hasVue) plugins.push('vue');
24
- if (hasSvelte) plugins.push('svelte3');
25
- return plugins;
26
- };
27
-
28
- const getOverrides = () => {
29
- const overrides = [];
30
- if (hasVue) overrides.push(require('../overrides/vue'));
31
- if (hasSvelte) overrides.push(require('../overrides/svelte'));
32
- return overrides;
33
- };
34
-
35
- module.exports = {
36
- hasVue,
37
- hasSvelte,
38
- getExtends,
39
- getPlugins,
40
- getOverrides,
41
- };
package/webapp.js DELETED
@@ -1,31 +0,0 @@
1
- const {
2
- getExtends, getPlugins, getOverrides, hasVue,
3
- } = require('./utils');
4
-
5
- const client = require('./shared/client');
6
- const universal = require('./shared/universal');
7
-
8
- module.exports = {
9
- extends: getExtends(),
10
- plugins: getPlugins(),
11
- parserOptions: {
12
- // Vue plugin uses Espree for ECMA versions, 'latest' does not work.
13
- ecmaVersion: hasVue ? 2021 : 'latest',
14
- sourceType: 'module',
15
- },
16
- overrides: [
17
- {
18
- files: [
19
- '*.vue',
20
- ],
21
- ...client,
22
- },
23
- {
24
- files: [
25
- '*.svelte',
26
- '*.js',
27
- ],
28
- ...universal,
29
- },
30
- ].concat(getOverrides()),
31
- };