@itskyedo/eslint-config v0.2.0
@itskyedo/eslint-config
- 🌈 Simple no-hassle configuration
- 💭 Opinionated but customizable
- 📦 Includes out-of-the-box support for useful plugins
- TypeScript support
- Prettier support
- Stylistic rules
- Validate proper imports
- Lint JSDoc comments
- Enforce best practices for promises
- Sort imports, exports, objects, and types
- and more to come
🗒️ Notes
This is a simple and modular way to setup projects with ESLint. Since the configuration is based on my own personal preferences, there may be rules that you may not want. However, plugins are optional and rules are easy to customize if necessary.
!WARNING The project is still in its early stages so there may be bugs and/or unwanted behavior until the
v1.0.0
release.
🚀 Getting Started
Prerequisites
- ESLint v9+
Installation
npm install -D @itskyedo/eslint-config
📚 API Reference
function createConfig
Initializes the ESLint config.
Parameter | Type | Description |
---|---|---|
options | ConfigOptions | The customizable options. |
...customConfigs | Linter.Config[] | Additional configuration objects and overrides. |
Returns: Linter.Config[]
An ESLint flat config array.
interface ConfigOptions
Property | Type | Description | Link |
---|---|---|---|
library | boolean | Whether to use the recommended rules for libraries. | |
ignores? | boolean \| IgnoresConfigOption | Additional ignores configuration. | |
base? | Partial<Linter.RulesRecord> | Overrides for the default base rules. | eslint |
typescript | boolean \| Partial<Linter.RulesRecord> | Overrides for the default TypeScript rules | typescript-eslint |
jsdoc | boolean \| Partial<Linter.RulesRecord> | Overrides for the default JSDoc rules. | eslint-plugin-jsdoc |
import | boolean \| Partial<Linter.RulesRecord> | Overrides for the default import rules. | eslint-plugin-import-x |
promise | boolean \| Partial<Linter.RulesRecord> | Overrides for the default promise rules. | eslint-plugin-promise |
sort | boolean \| Partial<Linter.RulesRecord> | Overrides for the default sort rules. | eslint-plugin-sort |
stylistic | boolean \| Partial<Linter.RulesRecord> | Overrides for the default stylistic rules. | eslint-stylistic |
prettier | boolean \| Partial<Linter.RulesRecord> | Overrides for the default prettier rules. | eslint-plugin-prettier |
interface IgnoresConfigOption
The configuration settings for ignores
.
Parameter | Type | Description |
---|---|---|
globs | string[] | The customizable options. |
gitignore? | boolean \| { cwd: string } (default: true) | Whether to ignore all globs listed in the project's .gitignore . Optionally, pass in an object to specify additional options. |
💡 Examples
Simple project setup
Set to true
to enable the default rules or false
to disable the plugin. Optionally, an object can be passed to add or override the default rules for that plugin.
Note that the name of the plugin is required when adding or override rules. Plugins are loaded in the order listed in ConfigOptions
.
// eslint.config.mjs
import createConfig from '@itskyedo/eslint-config';
export default createConfig({
library: true,
base: {
'no-unused-vars': 'off',
},
typescript: true,
jsdoc: true,
import: {
'import-x/consistent-type-specifier-style': 'off',
},
promise: true,
sort: true,
stylistic: false,
prettier: true,
});
Setup with other configs
You can pass all other configs as the last arguments.
Note that prettier
will always be loaded last within createConfig
so that it can override conflicting rules.
// eslint.config.mjs
import createConfig from '@itskyedo/eslint-config';
export default createConfig(
{
library: true,
typescript: true,
jsdoc: true,
import: true,
promise: true,
sort: true,
stylistic: false,
prettier: true,
},
// Other configs below
{
files: ['**/*.js'],
rules: {
semi: 'error',
'no-unused-vars': 'error',
},
}
);
📃 License
MIT License. See LICENSE for details.