This allows you to effectively track module usage.
wrong:
export default class Some {}
//...
import Some from './some';
Right:
export class Some {}
//...
import { Some } from './some';
For better tree-shaking and less code cohesion. It also avoids circular dependencies.
Wrong:
import { trim, isString, htmlspecialchars } from '../core/helpers';
Right:
import { trim } from 'jodit/core/helpers/string/trim';
import { isString } from 'jodit/core/helpers/checkers/is-string';
import { htmlspecialchars } from 'jodit/core/helpers/html/htmlspecialchars';
If several modules are imported from one place, then you can use the most extreme shortcut
Wrong:
import { trim, isString, isUrl } from 'jodit/core/helpers';
Right:
import { trim } from 'jodit/core/helpers/string/trim';
import { isString, isUrl } from 'jodit/core/helpers/checkers';
Imports should be in the following order
- Styles
- Global types
- Global modules
- Local types
- Local modules
Don't forget the
type
keyword if you only need the type:
Wrong:
import './config';
import type { LocalType } from './interface';
import { isString } from 'jodit/core/helpers/checkers/is-string';
import { IJodit } from 'jodit/types';
import './styles.less';
Right:
import './styles.less';
import type { IJodit } from 'jodit/types';
import { isString } from 'jodit/core/helpers/checkers/is-string';
import type { LocalType } from './interface';
import './config';
folder/subfolder/some.ts
export function some1(){}
export function some2(){}
folder/subfolder/another.ts
export function another1(){}
export function another2(){}
folder/subfolder/index.ts
export * from "./some"
export * from "./another"
folder/index.ts
export * from "./subfolder"