Skip to content

Latest commit

 

History

History
165 lines (115 loc) · 14 KB

README.md

File metadata and controls

165 lines (115 loc) · 14 KB

@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-danglechanged – set to enforce dangling commas in arrays, objects, imports and exports
  • 🔧 no-unused-varschanged – 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

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-modulechanged – 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