@soleil-se/eslint-config 3.1.0 → 4.0.1

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,64 @@ 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.1] - 2023-03-27
9
9
 
10
- ### Ändrat
10
+ - Läs bara in overrides för Svelte-filer när Svelte är installerat i projektet.
11
11
 
12
- - Tillåt användning av `console.error()` - för använding i exempelvis try catch.
12
+ ## [4.0.0] - 2022-06-22
13
13
 
14
- ## [3.0.1] - 2022-02-07
14
+ - Förenkla genom att ta bort de de olika konfigurationerna och använd en och samma config för allt utom legacy kod.
15
+ - Modernisera legacy konfigurationen för att tillåta begränsad användning av ES2015+ som stöds av Rhino.
16
+ - Använd `eslint-config-prettier` i Svelte komponenter för att undvika krockar med ESLint.
17
+ - Ta bort stöd för Vue.
15
18
 
16
- ### Ändrat
19
+ ## [3.1.0] - 2022-04-11
20
+
21
+ - Tillåt användning av `console.error()` - för exempelvis try catch.
22
+
23
+ ## [3.0.1] - 2022-02-07
17
24
 
18
25
  - Ignorera `import/no-unresolved` för importer som börjar med `@sitevision/api/server`,
19
26
  `@sitevision/api/common` och `@sitevision/api/client` då alla API:er inte finns dokumenterade.
20
27
 
21
28
  ## [3.0.0] - 2022-02-07
22
29
 
23
- ### Ändrat
24
-
25
30
  - Tillåt enbart importer av Sitevisions API:er via `@sitevision/api`.
26
31
  - Uppdaterat sökvägarna i den globala och webapp configen för att stödja WebApps 2 strukturen.
27
32
  - Uppdaterat `peerDependencies` till senaste major versionerna.
28
33
 
29
34
  ## [2.4.5] - 2021-11-04
30
35
 
31
- ### Fixat
32
-
33
36
  - Sätt `ecmaVersion` till 2021 i client kontfigurationen om Vue används.
34
37
 
35
38
  ## [2.4.4] - 2021-09-09
36
39
 
37
- ### Fixat
38
-
39
40
  - Lägg till `options` i `svelteSortOrder`.
40
41
 
41
42
  ## [2.4.3] - 2021-08-27
42
43
 
43
- ### Fixat
44
-
45
44
  - Felstavning i regeln `no-return-assign` i Svelte-filer.
46
45
 
47
46
  ## [2.4.2] - 2021-08-17
48
47
 
49
- ### Fixat
50
-
51
48
  - 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
49
 
53
50
  ## [2.4.1] - 2021-08-17
54
51
 
55
- ### Ändrat
56
-
57
52
  - Sätt `ecmaVersion` till `latest` för att slippa uppdatera version varje år.
58
53
 
59
54
  ## [2.4.0] - 2021-03-24
60
55
 
61
- ### Nytt
62
-
63
56
  - Meddelande av deprekering för konfigurationerna `@soleil/eslint-config-sitevision/universal` och `@soleil/eslint-config-sitevision/server`
64
57
  - Nya konfigurationer med tydligare namn: `@soleil/eslint-config-sitevision/webapp` och `@soleil/eslint-config-sitevision/server-legacy`
65
-
66
- ### Ändrat
67
-
68
58
  - Tillåt fler properties per rad i ett objekt i `object-curly-newline`.
69
59
 
70
60
  ## [2.3.1] - 2021-02-24
71
61
 
72
- ### Ändrat
73
-
74
62
  - Dra tillbaka till `ecmaVersion` till 2020.
75
63
 
76
64
  ## [2.3.0] - 2021-02-24
77
65
 
78
- ### Ändrat
79
-
80
66
  - Fler regler överlappar när man skriver universell kod.
81
67
  - Slagit av `import/prefer-default-export`.
82
68
  - Slagit av `no-return-assig` i Svelte komponenter.
@@ -84,77 +70,52 @@ och projektet använder [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
84
70
 
85
71
  ## [2.2.1] - 2021-01-07
86
72
 
87
- ### Fixat
88
-
89
73
  - Tagit bort `babel-eslint` från dependencies.
90
74
 
91
75
  ## [2.2.0] - 2021-01-07
92
76
 
93
- ### Ändrat
94
-
95
77
  - Tagit bort `babel-eslint` och använder standardparsern med ES2020.
96
78
  - Förenklat `svelte.config.js`, oftast behövs inte plugin för globbing.
97
79
  - Lagt till paketet `cache` som undantag för SiteVision paket.
98
80
 
99
81
  ## [2.1.4] - 2020-10-26
100
82
 
101
- ### Fixat
102
-
103
83
  - Tagit bort felaktig konfiguration av `a11y-no-onchange`.
104
84
 
105
85
  ## [2.1.3] - 2020-10-21
106
86
 
107
- ### Ändrat
108
-
109
87
  - Lagt till `app_src/views/**/*.js` i server configen.
110
88
 
111
89
  ## [2.1.2] - 2020-10-06
112
90
 
113
- ### Fixat
114
-
115
- - Felaktiga `parserOptions` i `server-es6` configen.
91
+ - Åträgrdat felaktiga `parserOptions` i `server-es6` configen.
116
92
 
117
93
  ## [2.1.1] - 2020-10-06
118
94
 
119
- ### Ändrat
120
-
121
- - Ordning på config så de inställningar Svelte behöver för serversidan kommer med.
95
+ - Ändrat ordning på config så de inställningar Svelte behöver för serversidan kommer med.
122
96
 
123
97
  ## [2.1.0] - 2020-09-28
124
98
 
125
- ### Ändrat
126
-
127
99
  - Dependencies som behövs som standard ligger som peerDependencies
128
100
  - Dependencies för ramverksspecifika plugins behöver installeras utöver peerDependencies.
129
101
 
130
102
  ## [2.0.0] - 2020-09-28
131
103
 
132
- ### Ändrat
133
-
134
104
  - Stöd för Svelte.
135
105
  - Uppdaterad struktur.
136
106
  - Uppdatering till ESLint 7.
137
-
138
- ### Tagit bort
139
-
140
- - Konfigurationen för Vue, ligger nu i client.
107
+ - Tagit bort konfigurationen för Vue, ligger nu i client.
141
108
 
142
109
  ## [1.1.2] - 2020-02-05
143
110
 
144
- ### Ändrat
145
-
146
111
  - Ändrat regeln `import/extensions` så den ignorerar json-filer.
147
112
 
148
113
  ## [1.1.1] - 2020-01-27
149
114
 
150
- ### Ändrat
151
-
152
115
  - Ändrat regeln `import/extensions` så den ignorerar vue-filer.
153
116
 
154
117
  ## [1.1.0] - 2020-01-21
155
118
 
156
- ### Ändrat
157
-
158
119
  - Ändrat regeln `import/extensions` så den ignorerar paket, löser problem med import via alias.
159
120
 
160
121
  ## [1.0.0] - 2020-01-13
@@ -165,24 +126,16 @@ och projektet använder [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
165
126
 
166
127
  ## [0.3.3] - 2019-12-06
167
128
 
168
- ### Ändrat
169
-
170
129
  - Det får nu vara max 3 attribut per rad i Vue (`vue/max-attributes-per-line`).
171
130
 
172
131
  ## [0.3.2] - 2019-06-03
173
132
 
174
- ### Fixat
175
-
176
133
  - Lagt till `server_src/api` i server på den globala configen.
177
134
 
178
135
  ## [0.3.1] - 2019-05-20
179
136
 
180
- ### Ändrat
181
-
182
137
  - Slagit av `global-require` för att kunna skriva `require` innanför IIFE i `src/index.js` i en WebApp.
183
138
 
184
139
  ## [0.3.0] - 2019-05-20
185
140
 
186
- ### Nytt
187
-
188
141
  - 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,60 @@
1
1
 
2
- # `@soleil-se/eslint-config-sitevision@^3.0.0`
2
+ # `@soleil-se/eslint-config-sitevision@^4.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
+ ```sh
22
+ > npm install @soleil-se/eslint-config-sitevision eslint eslint-config-airbnb-base eslint-plugin-import --save-dev
23
+ > yarn add @soleil-se/eslint-config-sitevision eslint eslint-config-airbnb-base eslint-plugin-import --dev
24
+ ```
58
25
 
59
26
  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
27
 
62
- ### Vue
28
+ ```sh
29
+ > npm install eslint-plugin-svelte3 svelte svelte-preprocess eslint-config-prettier --save-dev
30
+ > yarn add eslint-plugin-svelte3 svelte svelte-preprocess eslint-config-prettier --dev
31
+ ```
32
+
33
+ ## Uppgradera
34
+
35
+ ### Version 3.x.x > 4.x.x
63
36
 
64
- Om Vue används i projektet:
65
- `yarn add eslint-plugin-vue@^7.0.0 vue-eslint-parser@^7.0.0 --dev`
37
+ - Om Vue används i projektet **stanna** på version 3, stödet för Vue plockas bort i denna version.
38
+ - Uppgradera `@soleil-se/eslint-config-sitevision` till version 4 med `yarn upgrade @soleil-se/eslint-config-sitevision@latest`.
39
+ - Om Svelte används i projektet installera `eslint-config-prettier` med `yarn add eslint-config-prettier --dev`.
40
+ - Byt ut alla importer av konfigurationer:
41
+ - `@soleil-se/eslint-config-sitevision/global` > `@soleil-se/eslint-config-sitevision`
42
+ - `@soleil-se/eslint-config-sitevision/webapp` > `@soleil-se/eslint-config-sitevision`
43
+ - `@soleil-se/eslint-config-sitevision/client` > `@soleil-se/eslint-config-sitevision`
44
+ - `@soleil-se/eslint-config-sitevision/server-es6` > `@soleil-se/eslint-config-sitevision`
45
+ - `@soleil-se/eslint-config-sitevision/universal` > `@soleil-se/eslint-config-sitevision`
46
+ - Byt ut alla importer av legacy-konfigurationer:
47
+ - `@soleil-se/eslint-config-sitevision/server-legacy` > `@soleil-se/eslint-config-sitevision/legacy`
48
+ - `@soleil-se/eslint-config-sitevision/server` > `@soleil-se/eslint-config-sitevision/legacy`
66
49
 
67
- ## Uppgradera 2.x.x -> 3.x.x
50
+ ### Version 2.x.x > 3.x.x
68
51
 
69
52
  - Uppgradera `@soleil-se/eslint-config-sitevision` till version 3.
70
53
  - Uppgradera `eslint` till version 8.
71
54
  - Uppgradera `eslint-config-airbnb-base` till version 15.
72
55
  - Ändra importer till Sitevisions API:er till `@sitevision/api/(server|common|client)/NamnPåAPI`.
73
56
 
74
- ## Uppgradera 1.x.x -> 2.x.x
57
+ ### Version 1.x.x > 2.x.x
75
58
 
76
59
  - Uppgradera `eslint` till version 7.
77
60
  - Installera alla dependencies enligt installationssteget.
@@ -79,82 +62,35 @@ Om Vue används i projektet:
79
62
 
80
63
  ## Config
81
64
 
82
- ESLint läster främst från `.eslintrc.js` filer i projektet.
65
+ ESLint läser främst från `.eslintrc.js` filer i projektet.
83
66
  <https://eslint.org/docs/user-guide/configuring#using-configuration-files-1>
84
67
 
85
- ### Struktur
86
-
87
- [Här finns exempel på struktur](./docs/structure.md).
88
-
89
68
  ### Importera config
90
69
 
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
70
  ```js
108
71
  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
- }
72
+ extends: '@soleil-se/eslint-config-sitevision',
73
+ };
137
74
  ```
138
75
 
139
- I kontext med stöd för ES5.
140
- Till exempel serverkod som ska laddas upp som den är till Sitevision utan byggsteg.
76
+ Legacy config som används i en kontext med stöd för ES5 och delvis ES2015+.
77
+ Till exempel serverkod som ska laddas upp som den är till Sitevision utan kompilering.
141
78
 
142
79
  ```js
143
80
  module.exports = {
144
- extends: '@soleil-se/eslint-config-sitevision/server-legacy',
81
+ extends: '@soleil-se/eslint-config-sitevision/legacy',
145
82
  root: true,
146
- }
83
+ };
147
84
  ```
148
85
 
149
86
  ### ESLint ignore
150
87
 
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.
88
+ 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
89
 
153
90
  ```
154
91
  dist
155
92
  node_nodules
156
93
  **/node_nodules
157
- **/*.vm
158
94
  svelte.config
159
95
  ```
160
96
 
@@ -162,22 +98,15 @@ svelte.config
162
98
 
163
99
  Enklaste sättet att komma igång med ESLint är att installera det som extension i din editor.
164
100
 
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.
101
+ ### Visual Studio Code
169
102
 
170
- ```json
171
- {
172
- "eslint.packageManager": "yarn"
173
- }
174
- ```
103
+ Installera [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) till Visual Studio Code.
175
104
 
176
105
  #### End of line
177
106
 
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.
107
+ 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.
108
+ Ändra `\r\n` till `\n`.
109
+ Sen vill man även ha att en ny rad inkluderas i filerna.
181
110
 
182
111
  ```json
183
112
  {
@@ -199,7 +128,7 @@ Airbnb indenterar med två spaces.
199
128
 
200
129
  #### Autofix
201
130
 
202
- Man kan ställa in så enklare fel åtgärdas automatiskt under [settings](https://code.visualstudio.com/docs/getstarted/settings) i VS Code.
131
+ 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
132
 
204
133
  ```json
205
134
  {
@@ -211,8 +140,8 @@ Man kan ställa in så enklare fel åtgärdas automatiskt under [settings](https
211
140
 
212
141
  #### Max length
213
142
 
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).
143
+ Airbnb förespråkar en maxlängd på 100 tecken på en rad.
144
+ Man kan ställa in 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
145
 
217
146
  ```json
218
147
  {
@@ -222,68 +151,29 @@ Man kan ställa så man visar en linje i VS Code för att visualisera detta. Gö
222
151
  }
223
152
  ```
224
153
 
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
154
  #### Svelte
255
155
 
256
156
  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
157
 
258
158
  ```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
- ]
159
+ {
160
+ "eslint.validate": [
161
+ "javascript",
162
+ "javascriptreact",
163
+ "svelte"
164
+ ]
165
+ }
276
166
  ```
277
167
 
278
- #### Global konfig i underkatalog
168
+ #### Konfig i underkatalog
279
169
 
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.
170
+ 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
171
  Läs mer här: <https://github.com/microsoft/vscode-eslint#settings-options>
282
172
 
283
- Exempelvis om det ligger i mappen `@next`:
173
+ Exempelvis om det ligger i mappen `next`:
284
174
 
285
175
  ```json
286
- "eslint.workingDirectories": [".", { "directory": "./@next", "changeProcessCWD": true }],
176
+ "eslint.workingDirectories": [".", { "directory": "./next", "changeProcessCWD": true }],
287
177
  ```
288
178
 
289
179
  #### Komplett config
@@ -306,10 +196,7 @@ Exempelvis om det ligger i mappen `@next`:
306
196
  "eslint.packageManager": "yarn",
307
197
  "eslint.validate": [
308
198
  "javascript",
309
- "javascriptreact",
310
- "vue",
311
- "html",
312
- "velocity",
199
+ "javascriptreact",
313
200
  "svelte",
314
201
  ],
315
202
  "[svelte]": {
@@ -320,12 +207,12 @@ Exempelvis om det ligger i mappen `@next`:
320
207
 
321
208
  ## CLI
322
209
 
323
- Om man vill köra ESLint i sin terminal.
210
+ Om man vill köra ESLint i sin terminal.
324
211
  <https://eslint.org/docs/user-guide/command-line-interface>
325
212
 
326
213
  ## Svelte
327
214
 
328
- Installera [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) tillägget till VS Code för att få korrekt highlighing osv.
215
+ Installera [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) tillägget till Visual Studio Code.
329
216
 
330
217
  ### Kodformatering
331
218
 
@@ -338,7 +225,7 @@ Skapa en fil som heter `.prettierrc.js` i roten av projektet.
338
225
  module.exports = require('@soleil-se/eslint-config-sitevision/svelte.prettier');
339
226
  ```
340
227
 
341
- För att formatera automatiskt behöver man lägga till följande i `settings.json` i VS Code.
228
+ För att formatera automatiskt behöver man lägga till följande i `settings.json` i Visual Studio Code.
342
229
 
343
230
  ```json
344
231
  {
@@ -360,42 +247,6 @@ Man kan även stänga av formateringen av skript genom att lägga till kommentar
360
247
  <p>{foo}</p>
361
248
  ```
362
249
 
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
250
  ## Git
400
251
 
401
252
  Om man har problem med linebreaks i git kan man behöva göra följande:
@@ -407,5 +258,4 @@ Om man har problem med linebreaks i git kan man behöva göra följande:
407
258
  5. Kör: `git reset --hard`.
408
259
  6. Pusha upp filen.
409
260
 
410
- Mer info:
411
261
  <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: hasSvelte ? [{
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.1",
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.36.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.8.0",
13
+ "eslint-plugin-import": "^2.27.5",
14
+ "eslint-plugin-svelte3": "^4.0.0",
15
+ "svelte": "^3.57.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
- };