Skip to content

My personal ESLint config. Based on neostandard

License

Notifications You must be signed in to change notification settings

voxpelli/eslint-config

Repository files navigation

@voxpelli/eslint-config

npm version npm downloads neostandard javascript style Follow @voxpelli@mastodon.social

My personal ESLint config – a superset of the neostandard base config that I co-created and co-maintain.

This config contains a couple of more opinionated checks that I find helpful in my projects.

Install

To easily install correct peer dependencies, you can use install-peerdeps:

install-peerdeps --dev @voxpelli/eslint-config

Usage

Add an eslint.config.js (or eslint.config.mjs if your project is CJS) that exports this config:

export { default } from '@voxpelli/eslint-config';

If you need to configure something, instead do:

import { voxpelli } from '@voxpelli/eslint-config';

export default voxpelli({
  cjs: true,     // Ensures the config has rules fit for a CJS context rather than an ESM context
  noMocha: true, // By standard this config expects tests to be of the Mocha kind, but one can opt out
});

You can also do custom extensions:

import { voxpelli } from '@voxpelli/eslint-config';

export default [
  ...voxpelli({
    // Config options
  }),
  {
    // Custom ESLint config
  },
];

How does this differ from pure neostandard?

  • πŸ›‘ = changed to error level
  • ⚠️ = changed to warn level
  • πŸ”‡ = deactivated
  • πŸ”§ = changed config

πŸ”§ Changed neostandard rules

  • πŸ”§ @stylistic/comma-dangle – changed – set to enforce dangling commas in arrays, objects, imports and exports
  • πŸ”§ no-unused-vars – changed – sets "args": "all", "argsIgnorePattern": "^_", because I personally don't feel limited by Express error handlers + wants to stay in sync with TypeScript noUnusedParameters

βž• Added ESLint core rules

  • ⚠️ func-style – disallows function declarations, good to be consistent with how functions are declared
  • ⚠️ no-console – warns on existence of console.log and similar, as they are mostly used for debugging and should not be committed
  • πŸ›‘ no-constant-binary-expression – errors when binary expressions are detected to constantly evaluate a specific way
  • πŸ›‘ no-nonoctal-decimal-escape – there's no reason not to ban it
  • πŸ›‘ no-unsafe-optional-chaining – enforces one to be careful with .? and not use it in ways that can inadvertently cause errors or NaN results
  • ⚠️ no-warning-comments – warns of the existence of FIXME comments, as they should always be fixed before pushing
  • πŸ›‘ object-shorthand – requires the use of object shorthands for properties, more tidy

πŸ“¦ Added ESLint rule packages

πŸ”§ Overrides of added ESLint rule packages

βž• Additional standalone ESLint rules

  • πŸ›‘ @stylistic/quote-props – requires properties to be quoted when needed but otherwise disallows it

  • ⚠️ es-x/no-exponential-operators – disallows the use of the ** operator, as that's in most cases a mistake and one really meant to write *

ESM specific rules

Unless one configures cjs: true these additional rules will be applied:

πŸ”§ Overrides of rules

  • ⚠️ func-style – enforces function declarations whenever an arrow function isn't used. Better to do export function foo () { than export const foo = function () {
  • πŸ›‘ unicorn/prefer-module – changed – restored to its plugin:unicorn/recommended value of error

Can I use this in my own project?

You may want to use neostandard instead, it's the general base config that I help maintain for the community.

I do maintain this project though as if multiple people are using it, so sure, you can use it, but its ultimate purpose is to support my projects.

I do follow semantic versioning, so the addition or tightening of any checks will trigger major releases whereas minor and patch releases should only ever have relaxation of rules and bug fixes.

Alternatives

See also