Follow the rules in the ESLint configuration.
The Dojo style guide provides a lot of good guidance. There may be some differences in our ESLint configuration, in that case those take precedence.
- Use single quotes for string values, unless the string contains a single quote, in which case it is preferable to use double quotes and avoid escaping the single quotes in the content.
- Only quote property names when necessary (e.g. if they contain a dash or begin with '0')
- Module names should be camel cased
- Modules that primarily export a class should have the same name as the class (which should be CamelCase)
- Modules that do not export a class should have a descriptive name starting with lower case (camelCase)
- Modules should use named exports instead of default exports (further reading), e.g.:
- Functions and variables should be included in the final export:
function classHelper () {}
class MyClass {}
export { MyClass };
// or
export {
classHelper,
MyClass,
};
This export style makes it very easy to see in one place all exports from a module.
Module imports should be grouped:
- External dependencies (packages from Node.js or
node_modules
) - Project dependencies outside the current folder (
../**
) - Project dependencies from within the current folder (
./**
) - CSS imports (
import './MyModule.css';
)
Sorting within each group should be by package path and name, case-insensitive, and ignoring leading @