Licence
MIT
Version
1.0.3
Deps
0
Size
3 kB
Vulns
0
Weekly
0
eslint-plugin-use-optional-annotation
Disallow undefined for keeping structure.
The following will all be incorrect usage:
const foo = { x: 123, y: undefined };
The following will all be correct usage:
const foo: { x: number, y?: number } = { x: 123 };
We made it to keep this TypeScript styleguide's null-vs-undefined.
Installation
yarn add -D eslint-plugin-use-optional-annotation
# or npm i -D eslint-plugin-use-optional-annotation
Configuration
Set .eslintrc following
plugins: [
'use-optional-annotation' // add to `plugins` arrays final element.
],
// ...
rules: {
'use-optional-annotation/use-optional-annotation': 'error'
}