1.0.2 • Published 1 year ago

eslint-plugin-no-explicit-undefined v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

ESLint Plugin: eslint-plugin-no-explicit-undefined

Disallow the use of undefined as an explicit type in TypeScript and instead use optional operator (?) instead.

📚 Rule Examples

This rule disallows the use of undefined as an explicit type in TypeScript. Instead, developers should use optional properties or null.

Examples of incorrect code for this rule ❌

function example(param: string | undefined) {}
class Test { constructor(public prop: string | undefined) {} }
interface Example { prop: string | undefined; }

Examples of correct code for this rule ✅

function example(param?: string) {} 
class Test { constructor(public prop?: string) {} }
interface Example { prop?: string; }

🚀 Installation

Install the package using npm:

npm install eslint-plugin-no-explicit-undefined --save-dev

Install the package using yarn:

yarn add eslint-plugin-no-explicit-undefined --dev

Install the package using pnpm:

pnpm install eslint-plugin-no-explicit-undefined --save-dev

📝 Configuration

To configure the rule, add it to your ESLint configuration file (.eslintrc.json, .eslintrc.js, etc.):

{
  "extends": ["custom"],
  "plugins": ["no-undefined-type-declaration"],
  "rules": {
    "no-undefined-type-declaration/no-undefined-type": "error"
  }
}

📃 License

MIT

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago