Linting reference

Adapter linting uses ESLint with the AirBnB rule set and two modifications: the max line length rule is downgraded to a warning, and the comma-dangle rule is removed so that JSON files are formatted as valid JSON.

Linting scripts are defined in package.json. Run them from the adapter directory.

$npm run lint # all lint output, including warnings
$npm run lint:errors # errors only — suppresses warnings

Most adapters produce a large number of warnings. Running lint:errors makes it easier to find the issues that matter. Lint errors — especially syntax errors — can prevent the adapter from loading whenItential Platform restarts and can cause runtime failures. See Linting for guidance on when to run lint and what to do with errors.

Code style rules

#RuleExample
1Indentation must be 2 spaces.
2Use single quotes for strings. No double quotes.'I am a string'
3Use template literals when embedding variables in strings.`this adds a ${variable} into a string`
4Do not quote object keys.{ key: 'value' }
5Use dot notation for object property access.object.key
6Use bracket notation when a key contains a hyphen.object['my-key']
7Do not use ++ or --. Use += or -= instead.x += 1
8Place a space after commas.
9Place a space before curly braces on functions and objects.
10Place else on the same line as the closing } of if.
11Place catch on the same line as the closing } of try.
12No trailing spaces at the end of lines.