Strict Rules
The eslint-config-airbnb-extended
package comes with a set of stricter ESLint rules for Imports
, React
, and TypeScript
that go beyond the default configuration.
By default, these rules are not enabled, so you can choose whether your project needs them. They are best suited for teams that want maximum consistency, fewer edge-case bugs, and stronger guarantees around code quality.
How to Enable Strict Rules
To enable strict rules, import them directly from the package:
import { rules } from 'eslint-config-airbnb-extended';
Then extend them in your ESLint configuration file (eslint.config.mjs
):
export default [
// Your existing configs
rules.base.importsStrict,
rules.react.strict,
rules.typescript.typescriptEslintStrict,
];
This setup ensures that the strict rules are applied on top of your current configuration, without losing flexibility to override them later.
What Do These Strict Rules Include?
1. Strict Imports
These rules are designed to keep your imports organized, efficient, and predictable. Key features include:
- Enforcing a consistent and logical import order (e.g., external → internal → local modules).
- Differentiating clearly between type imports (
import type
) and value imports. - Preventing duplicate imports or unnecessary re-exports.
- Detecting unresolved imports earlier.
- and many more...
This ensures your codebase remains clean and easy to navigate, even as it scales.
2. Strict React
These rules ensure React code stays readable, predictable, and TypeScript-friendly. Key features include:
- Enforcing
key
props on list-rendered elements to prevent rendering bugs. - Sorting JSX props for consistent readability across components.
- Disabling
prop-types
since TypeScript provides stronger typing guarantees. - and many more...
This results in more consistent React components and fewer runtime issues.
3. Strict TypeScript ESLint
These rules encourage best practices in TypeScript and protect against unsafe patterns. Key features include:
- Disallowing
@ts-ignore
in favor of@ts-expect-error
, making ignored errors intentional and visible. - Banning the use of
any
to maintain strict typing guarantees. - Disallowing non-null assertions (
!
) that can hide potential runtime errors. - Encouraging modern TypeScript features like the Nullish Coalescing Operator (
??
) and Optional Chaining (?.
). - and many more...
This keeps your TypeScript code robust, maintainable, and future-proof.
When To Use Strict Rules?
Strict Rules is ideal for teams or projects that:
- Want maximum consistency across the codebase.
- Need stricter guarantees around type safety and React usage.
- Prefer a "lint-first, catch bugs early" development philosophy.
If your team values flexibility and faster prototyping, the default configuration may be sufficient. But if your goal is production-grade reliability and long-term maintainability, enabling Strict Rules is highly recommended.