@armadacore/eslint-plugin-essentials
v0.1.0
Published
ESLint plugin enforcing @armadacore/essentials patterns: handle Result errors, default optional parameters
Maintainers
Readme
@armadacore/eslint-plugin-essentials
ESLint plugin that enforces patterns from @armadacore/essentials:
result-must-handle-err—IResult<T>values must have their error path handled.optional-must-have-default— Optional function/method parameters and return types must not leakundefined/null.
Install
npm install -D @armadacore/eslint-plugin-essentialsPeer dependencies: eslint >=9, typescript >=5.
Usage (flat config)
// eslint.config.js
import essentials from '@armadacore/eslint-plugin-essentials';
import tseslint from 'typescript-eslint';
export default [
...tseslint.configs.recommendedTypeChecked,
...essentials.configs.recommended,
{
languageOptions: {
parserOptions: {
project: './tsconfig.json',
},
},
},
];Both rules require parserServices (i.e. a TypeScript program). Without parserOptions.project, the rules will silently no-op.
Rules
result-must-handle-err
Reports any IResult<T> value whose Err branch is never handled.
Accepted as handling: onErr, match, unwrapOr, unwrapOrElse, err, expectErr, orElse, ignoreErr.
Delegation also counts: return result, passing as argument, assignment to a container.
See docs/rules/result-must-handle-err.md.
optional-must-have-default
Reports function/method signatures that introduce undefined/null into the function body or its return value.
See docs/rules/optional-must-have-default.md.
Example
The example/ directory contains a real workspace using @armadacore/essentials with both valid and invalid code samples. Run:
npm install
npm run build
npm run example:lintLicense
MIT
