This document gives coding conventions for the JavaScript code. It is mostly concerned with syntax-level constructs.
Imports are sorted using two orderings. First-level import ordering is as follows:
- Wildcard imports (module imports)
- Selective imports (named-multiple imports)
- Default imports (singular imports)
Default imports mixed with other imports (e.g. import default, { foo, bar } from '/module.js'
should go wherever the second
part of the import should go).
Then, second-level ordering is as follows:
- Imports from other packages.
- Absolute imports.
- Relative imports.
import * as namespace from 'module-name'
import defaultExport, * as name from './file'
import { doStuff } from 'some/package'
import { doOtherStuff, doOthererStuff } from '@/some/place/in/project'
import { doSomethingElse as something } from './here'
import SomeUtil from '@/utils'
import SomeOtherUtil from '../almost/here'