A spiritual successor to the standard
javascript style guide
Initial development sponsored by:
Table of Contents
Quick Start
Migrate from standard
npm install -D neostandard eslint
npx neostandard --migrate > eslint.config.js
(uses our config helper)- Replace
standard
with eslint
in all places where you run standard
, eg. "scripts"
and .github/workflows/
(neostandard
CLI tracked in #2) - (Add ESLint editor integration, eg. VS Code ESLint extension)
- Cleanup:
npm uninstall standard
- Remove unused
"standard"
top level key from your package.json
- Deactivate
standard
specific integrations if you no longer use them (eg. vscode-standard))
Add to new project
-
npm install -D neostandard eslint
-
Add an eslint.config.js
:
Using config helper:
npx neostandard --esm > eslint.config.js
Or to get CommonJS:
npx neostandard > eslint.config.js
Or manually create the file as ESM:
import { neostandard } from 'neostandard'
export default neostandard({
})
Or as CommonJS:
module.exports = require('neostandard')({
})
-
Run neostandard
by running ESLint, eg. using npx eslint
, npx eslint --fix
or similar
Configuration options
env
- string[]
- adds additional globals by importing them from the globals npm modulefiles
- string[]
- additional file patterns to match. Uses the same shape as ESLint files
filesTs
- string[]
- additional file patterns for the TypeScript configs to match. Uses the same shape as ESLint files
globals
- string[] | object
- an array of names of globals or an object of the same shape as ESLint languageOptions.globals
ignores
- string[]
- an array of glob patterns for files that the config should not apply to, see ESLint documentation for detailsnoStyle
- boolean
- if set, no style rules will be added. Especially useful when combined with Prettier, dprint or similarsemi
- boolean
- if set, enforce rather than forbid semicolons (same as semistandard
did)ts
- boolean
- if set, TypeScript syntax will be supported and *.ts
(including *.d.ts
) will be checked. To add additional file patterns to the TypeScript checks, use filesTs
resolveIgnoresFromGitignore()
Finds a .gitignore
file that recides in the same directory as the ESLint config file and returns an array of ESLint ignores that matches the same files.
ESM:
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
export default neostandard({
ignores: resolveIgnoresFromGitignore(),
})
CommonJS:
module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
})
Missing for 1.0.0 release
- Add JSX/TSX support: #11
- Migrate
eslint-plugin-promise
rules from standard
: #14 - Migrate
eslint-plugin-import
rules from standard
: #15 - Investigate a dedicated
neostandard
runner: #2
Full list in 1.0.0 milestone
Differences to standard / eslint-config-standard 17.x
Changed rules
@stylistic/comma-dangle
– changed – set to prefer dangling commas in everything but functions and is it set to warn
rather than error
Relaxed rules
Missing bits
- Some plugins are not yet supporting ESLint 9 or flat configs and has thus not yet been added. These are:
eslint-plugin-import
and eslint-plugin-promise
- JSX parsing is not supported out of the box
Config helper
You can use the provided CLI tool to generate a config for you:
neostandard --semi --ts > eslint.config.js
To see all available flags, run:
neostandard --help
Config migration
The CLI tool can also migrate an existing "standard"
configuration from package.json
:
neostandard --migrate > eslint.config.js
Migrations can also be extended, so to eg. migrate a semistandard
setup, do:
neostandard --semi --migrate > eslint.config.js
Readme badges
Yes! If you use neostandard
in your project, you can include one of these badges in
your readme to let people know that your code is using the neostandard style.
[![neostandard javascript style](https://img.shields.io/badge/neo-standard-7fffff?style=flat&labelColor=ff80ff)](https://github.com/neostandard/neostandard)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-7fffff?style=flat&labelColor=ff80ff)](https://github.com/neostandard/neostandard)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)