0.2.0 • Published 9 months ago

@itskyedo/eslint-config v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@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.

ParameterTypeDescription
optionsConfigOptionsThe customizable options.
...customConfigsLinter.Config[]Additional configuration objects and overrides.

Returns: Linter.Config[] An ESLint flat config array.

interface ConfigOptions

PropertyTypeDescriptionLink
librarybooleanWhether to use the recommended rules for libraries.
ignores?boolean \| IgnoresConfigOptionAdditional ignores configuration.
base?Partial<Linter.RulesRecord>Overrides for the default base rules.eslint
typescriptboolean \| Partial<Linter.RulesRecord>Overrides for the default TypeScript rulestypescript-eslint
jsdocboolean \| Partial<Linter.RulesRecord>Overrides for the default JSDoc rules.eslint-plugin-jsdoc
importboolean \| Partial<Linter.RulesRecord>Overrides for the default import rules.eslint-plugin-import-x
promiseboolean \| Partial<Linter.RulesRecord>Overrides for the default promise rules.eslint-plugin-promise
sortboolean \| Partial<Linter.RulesRecord>Overrides for the default sort rules.eslint-plugin-sort
stylisticboolean \| Partial<Linter.RulesRecord>Overrides for the default stylistic rules.eslint-stylistic
prettierboolean \| Partial<Linter.RulesRecord>Overrides for the default prettier rules.eslint-plugin-prettier

interface IgnoresConfigOption

The configuration settings for ignores.

ParameterTypeDescription
globsstring[]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.