Skip to content

Commit 50c6a80

Browse files
committed
import/export order
1 parent a77f124 commit 50c6a80

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

js/red-javascript-style-guide/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-red",
3-
"version": "1.8.2",
3+
"version": "1.8.3",
44
"license": "CC0-1.0",
55
"homepage": "https://github.com/GrosSacASac/JavaScript-Set-Up/tree/master/js/red-javascript-style-guide",
66
"files": [

js/red-javascript-style-guide/readme.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,26 @@ Put them at the top of the file as they will be executed first. Put exports befo
278278

279279
```js
280280
export { y };
281+
282+
import FastAverageColor from "fast-average-color/dist/index.esm.js";
281283
import { x } from "./x.js";
282284
import * as z from "./z.js";
283-
import FastAverageColor from "fast-average-color/dist/index.esm.js";
285+
284286

285287
const y = 5;
286288
```
287289

290+
#### import/export order
291+
292+
1. exports with optional line break
293+
2. imports of standard library
294+
3. imports of runtime library (NodeJS, Deno, etc)
295+
4. imports of external dependencies
296+
5. imports of local files
297+
6. optional line break
298+
7. declaration of constants that are import related (some libraries only export default)
299+
8. optional two line breaks then begin of code
300+
288301
### Limit variable reach
289302

290303
Historically it has been done with an immediately invoked function expression, now that let and const are available and block scoped use a simple block. With an iife:

0 commit comments

Comments
 (0)