![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@nickkaramoff/eslint-config
Advanced tools
My own shareable ESLint config.
This config enforces reasonable code style rules for style for JavaScript and TypeScript codebases. Each rule has a reason why it was added (see below).
npm install --save-dev @nickkaramoff/eslint-config
yarn add --dev @nickkaramoff/eslint-config
Then, in your ESLint config:
{
"extends": "@nickkaramoff"
}
Every --fix
able rule is always an error
.
array-bracket-newline: consistent
Consistency is key to code readability. Placing a line break in arrays increases
readability, but for arrays like [1, 2, 3]
it is unnecessary.
camelcase
camelCase is used by most JavaScript developers. I also find it more beautiful than any other naming convention.
comma-dangle: always-multiline
Dangling commas at the end of multi-line literals (arrays, objects) can clean up your git diffs and save your from conflicts.
complexity
Reducing the cyclomatic complexity of the code improves readability and reduces error risk. This is not an enforcement though, but a recommendation.
curly: all
Not using curly braces in if
, while
and other statements decreases the code
readability significantly. Nesting is fine, but I go for consistency in code.
dot-location: property
When the attribute dot is placed after the object, the subsequent property name on the new line seems out of place. Placing the dot at the property increases readability. Seeing, that there is neither a dot nor a semi near the object tells us to look at the next line, where the dot will explain the reason for the line break.
dot-notation
It is cleaner and more correct to access an object's properties via a dot. If
you use JS objects as dictionaries, don't — there is a Map
for that.
eol-last: always
Add an EOL at the end of the files to be able to concatenate them easily or output them to terminal without errors.
eqeqeq: always
===
is typesafe and will save you tons of headache when comparing things in
JavaScript. null
is not ignored for consistency.
for-direction
Saves you from for
loops that run endlessly because of a faulty counter.
indent: tab
Using Tabs lets people choose their desired indent size while keeping the file size smaller. A double win!
offsetTernaryExpressions: true
, because this is more correct visuallySwitchCase: 1
, because this increases readabilitylinebreak-style: unix
Unix-style linebreaks are cleaner and take less space. IMO, LF should be a standard for line endings (and it de facto is). Every major editor (even notepad.exe) supports it as of 2020.
no-extra-semi
Extra semicolons are unnecessary and pollute source code.
no-implicit-coercion
Shorthands like !!foo
and +bar
for type casting can be clean at the first
glance but they are unclear, especially for the beginners.
no-trailing-spaces
Trailing spaces are useless and only take space.
quotes: single
Single quotes are easier to type and look cleaner.
allowTemplateLiterals: false
, because it's unnecessary when you don't use
interpolationavoidEscape: true
, because escaping looks even less clean than double quotessemi: always
Mandatory semicolons help people make less errors by not making them think about where JavaScript will automatically insert them.
semi-spacing
Spaces are only allowed after semicolons, just like in written languages.
wrap-iife: inside
IIFEs can be confusing, but wrapping the function separately from the call (and
Function
's methods) is IMO the cleanest solution.
functionPrototypeMethods: true
, because methods of Function
are, just like
the function calls, separate from the function bodyyoda: never
Yoda-style conditions are unnatural for the English language (which JS is based on)
ISC © 2020-2021, Nikita Karamov
[0.4.0] - 2021-03-23
FAQs
Nikita Karamov's shareable ESLint config
The npm package @nickkaramoff/eslint-config receives a total of 1 weekly downloads. As such, @nickkaramoff/eslint-config popularity was classified as not popular.
We found that @nickkaramoff/eslint-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.