@newfadel/eslint-config
v1.0.1
Published
ESLint configuration for TypeScript projects with comprehensive linting rules
Downloads
20
Maintainers
Readme
@newfadel/eslint-config
Comprehensive ESLint configuration for TypeScript projects with opinionated linting rules.
Features
- 🎯 TypeScript-first: Optimized for TypeScript projects
- 🚀 Modern ES2020: Uses latest ECMAScript features
- 📦 Import sorting: Automatic import organization
- 🎨 Code formatting: Consistent code style enforcement
- ⚡ Performance: Optimized rules for better development experience
Installation
Install the package and its peer dependencies:
```bash npm install --save-dev @newfadel/eslint-config eslint typescript ```
Or with yarn:
```bash yarn add --dev @newfadel/eslint-config eslint typescript ```
Usage
Create an `.eslintrc.json` file in your project root:
```json { "extends": "@newfadel" } ```
Or use `.eslintrc.js`:
```javascript module.exports = { extends: '@newfadel' } ```
Or use `.eslintrc.yaml`:
```yaml extends: '@newfadel' ```
Configuration
This ESLint config includes rules for:
TypeScript
- Prevents misused promises
- Enforces optional chaining
- Removes unnecessary type assertions
- Warns about explicit `any` usage
- Handles unused variables properly
Code Style
- Tab indentation
- Single quotes
- No semicolons
- Unix line endings
- Proper spacing and formatting
Import Organization
- Automatic import sorting
- Grouped imports by type
- Consistent import order
Code Quality
- Maximum nesting depth of 4
- Prevents constant conditions
- Enforces camelCase naming
- Requires curly braces
- Prevents multiple empty lines
Rules Overview
Key Rules Included:
- `@typescript-eslint/no-misused-promises`: Prevents Promise misuse
- `@typescript-eslint/prefer-optional-chain`: Enforces optional chaining
- `@typescript-eslint/no-explicit-any`: Warns about `any` usage
- `simple-import-sort/imports`: Sorts imports automatically
- `no-restricted-syntax`: Prevents enum declarations
- `prefer-const`: Enforces const for immutable variables
- `eqeqeq`: Requires strict equality
Customization
You can extend or override rules in your `.eslintrc.json`:
```json { "extends": "@newfadel", "rules": { "indent": ["error", 2], "quotes": ["error", "double"] } } ```
Scripts
Add these scripts to your `package.json`:
```json { "scripts": { "lint": "eslint . --ext .ts,.tsx,.js,.jsx", "lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx --fix" } } ```
Peer Dependencies
This config requires:
- eslint: Any version
- typescript: Version 4 or higher
License
MIT License - see the LICENSE file for details.
Contributing
- Fork the repository
- Create your feature branch (`git checkout -b feature/amazing-feature`)
- Commit your changes (`git commit -m 'Add some amazing feature'`)
- Push to the branch (`git push origin feature/amazing-feature`)
- Open a Pull Request
Changelog
1.0.0
- Initial release
- TypeScript ESLint rules
- Import sorting
- Comprehensive code style rules ```
MIT License
Copyright (c) 2025 newfadel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.