A modern successor to standard
npm install neostandard


A spiritual successor to the standard javascript style guide
Initial development sponsored by:
src="assets/platformatic.svg"
width="450"
height="auto"
alt="platformatic"
/>
- Quick Start
- Migrate from standard
- Add to new project
- Configuration options
- Extending
- Additional exports
- resolveIgnoresFromGitignore()
- Exported plugins
- List of exported plugins
- Usage of exported plugin
- Missing for 1.0.0 release
- Differences to standard / eslint-config-standard 17.x
- Relaxed rules
- Config helper
- Config migration
- Readme badges
- Mission statement
- Rule guidelines
- Governance
- Used by
1. npm install -D neostandard eslint
2. (Validate that it runs cleanly by running npx neostandard --help, see #267)
3. npx neostandard --migrate > eslint.config.js (uses our config helper)
4. Replace standard with eslint in all places where you run standard, eg. "scripts" and .github/workflows/ (neostandard CLI tracked in #2)
5. (Add ESLint editor integration, eg. VS Code ESLint extension)
6. 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))
1. npm install -D neostandard eslint
2. Add an eslint.config.js:
Using config helper:
``sh`
npx neostandard --esm > eslint.config.js
Or to get CommonJS:
`sh`
npx neostandard > eslint.config.js
Or manually create the file as ESM:
`js
import neostandard from 'neostandard'
export default neostandard({
// options
})
`
Or as CommonJS:
`js`
module.exports = require('neostandard')({
// options
})
neostandard
3. Run by running ESLint, eg. using npx eslint, npx eslint --fix or similar
All examples below use ESM (ECMAScript Modules) syntax. If you're using CommonJS (CJS), replace the import/export statements with the following:
`js
// Replace
import neostandard from 'neostandard'
export default neostandard({ / options / })
// With
const neostandard = require('neostandard')
module.exports = neostandard({ / options / })
`
Here's a basic example of how to configure neostandard:
`js
import neostandard from 'neostandard'
export default neostandard({
ts: true, // an option
// Add other options here
})
`
The options below allow you to customize neostandard for your project. Use them to add global variables, ignore files, enable TypeScript support, and more.
env - string[]* - adds additional globals by importing them from the globals npm module`
js
import neostandard from 'neostandard'
export default neostandard({
env: ['browser', 'mocha'], // Add browser and mocha global variables
})
`
files - string[]* - additional file patterns to match. Uses the same shape as ESLint files`
js
import neostandard from 'neostandard'
export default neostandard({
files: ['src//.js', 'tests//.js'], // Lint only files in src/ and tests/ directories
})
`
filesTs - string[]* - additional file patterns for the TypeScript configs to match. Uses the same shape as ESLint files`
js
import neostandard from 'neostandard'
export default neostandard({
ts: true, // Enable TypeScript support
filesTs: ['src//.ts', 'tests//.ts'], // Lint only TypeScript files in src/ and tests/ directories
})
`globals
- string[] | object* - an array of names of globals or an object of the same shape as ESLint languageOptions.globals
Using an array:
`js
import neostandard from 'neostandard'
export default neostandard({
globals: ['$', 'jQuery'], // Treat $ and jQuery as global variables
})
`
Using an object:
`js
import neostandard from 'neostandard'
export default neostandard({
globals: {
$: 'readonly', // $ is a read-only global
jQuery: 'writable', // jQuery can be modified
localStorage: 'off', // Disable the localStorage global
},
})
`
ignores - string[]* - an array of glob patterns for files that the config should not apply to, see ESLint documentation for details`
js
import neostandard from 'neostandard'
export default neostandard({
ignores: ['dist//*', 'tests/'], // Ignore files in dist/ and tests/ directories
})
`
noJsx - boolean* - if set, no jsx rules will be added. Useful if for some reason its clashing with your use of JSX-style syntax`
js
import neostandard from 'neostandard'
export default neostandard({
noJsx: true, // Disable JSX-specific rules
})
`
noStyle - boolean* - if set, no style rules will be added. Especially useful when combined with Prettier, dprint or similar`
js
import neostandard from 'neostandard'
export default neostandard({
noStyle: true, // Disable style-related rules (useful with Prettier or dprint)
})
`
semi - boolean* - if set, enforce rather than forbid semicolons (same as semistandard did)`
js
import neostandard from 'neostandard'
export default neostandard({
semi: true, // Enforce semicolons (like semistandard)
})
`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`
js
import neostandard from 'neostandard'
export default neostandard({
ts: true, // Enable TypeScript support and lint .ts files
})
`
The neostandard() function returns an ESLint config array which is intended to be exported directly or, if you want to modify or extend the config, can be combined with other configs like any other ESLint config array:
`js
import neostandard from 'neostandard'
import jsdoc from 'eslint-plugin-jsdoc';
export default [
...neostandard(),
jsdoc.configs['flat/recommended-typescript-flavor'],
]
`
Do note that neostandard() is intended to be a complete linting config in itself, only extend it if you have needs that goes beyond what neostandard provides, and open an issue if you believe neostandard itself should be extended or changed in that direction.
It's recommended to stay compatible with the plain config when extending and only make your config stricter, not relax any of the rules, as your project would then still pass when using just the plain neostandard-config, which helps people know what baseline to expect from your project.
Finds a .gitignore file that resides in the same directory as the ESLint config file and returns an array of ESLint ignores that matches the same files.
ESM:
`js
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
export default neostandard({
ignores: resolveIgnoresFromGitignore(),
})
`
CommonJS:
`js`
module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
})
neostandard exports all the ESLint plugins that it uses. This to ensure that users who need to reference the plugin themselves will use the exact same instance of the plugin, which is a necessity when a plugin prefix is defined in multiple places.
#### List of exported plugins
* @stylistic - export of @stylistic/eslint-pluginimport-x
* - export of eslint-plugin-import-xn
* - export of eslint-plugin-npromise
* - export of eslint-plugin-promisereact
* - export of eslint-plugin-reacttypescript-eslint
* - export of typescript-eslint
#### Usage of exported plugin
If one eg. wants to add the eslint-plugin-n recommended config, then one can do:
`js
import neostandard, { plugins } from 'neostandard'
export default [
...neostandard(),
plugins.n.configs['flat/recommended'],
]
`
* Investigate a dedicated neostandard runner: #33 / #2
Full list in 1.0.0 milestone
* Open governance, resolving governance issue
* Built for ESLint 9
* Relies on ESLint flat config to bundle plugins rather than custom standard-engine
* Replaces deprecated ESLint style rules with eslint-stylistic rules
* Defaults to the standard behaviour of bundling JSX-support (ported from eslint-config-standard-jsx) with a noJsx option that deactivates it to match eslint-config-standardts
* Built in options replaces need for separate modules
option makes .ts files be checked as well (used to be handled by ts-standard)semi
* option enforces rather than ban semicolons (used to be handled by semistandard)noStyle
* option deactivates style rules (used to require something like eslint-config-prettier)
@stylistic/comma-dangle – changed* – set to ignore dangling commas in arrays, objects, imports, exports and is it set to warn rather than error@stylistic/no-multi-spaces
– changed* – sets ignoreEOLComments to true, useful for aligning comments across multiple linedot-notation
– deactivated* – clashes with the noPropertyAccessFromIndexSignature check in TypeScriptn/no-deprecated-api
– changed* – changed to warn instead of error as they are not urgent to fix
You can use the provided CLI tool to generate a config for you:
`sh`
neostandard --semi --ts > eslint.config.js
To see all available flags, run:
`sh`
neostandard --help
The CLI tool can also migrate an existing "standard" configuration from package.json:
`sh`
neostandard --migrate > eslint.config.js
Migrations can also be extended, so to eg. migrate a semistandard setup, do:
`sh`
neostandard --semi --migrate > eslint.config.js
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.

`md`


`md`


`md`

_Prior to the 1.0.0 release we are still rapidly evolving with fixes and improvements to reach rule parity with standard, hence more breaking changes will be experienced until then, as well as evolution of this statement_
neostandard intends to set an expectable baseline for project linting that's _descriptive_ of best practices rather than _prescriptive_ of any opinionated approach.
1. neostandard rules _describes_ current best practices in the community and help align developers, contributors and maintainers along thoseneostandard
2. rules _are not_ a tool to promote changed practices within the community by _prescribing_ new such practicesneostandard
3. rule changes and additions should be aligned with projects prior to being released, by eg. sending PR:s to them to align them ahead of time. When new best practices are incompatible with current best practices, rules should first be relaxed to allow for both approaches, then be made stricter when the community has moved to the new approachneostandard
4. rule changes and additions should improve the _description_ of project best practices, not _prescribe_ new practicesneostandard
5. should, when faced with no clear best practice, avoid adding such a rule as it risks becoming _prescriptive_ rather than _descriptive_. If leaving out such a rule would make neostandard an incomplete baseline config, and the community is split between a few clear alternatives (such as semi), then making it configurable can enable it to still be added, but that should only be done in exceptional cases
neostandard is a community project with open governance.
See GOVERNANCE.md for specifics.
A subset of some of the projects that rely on neostandard:
* bcomnes/npm-run-all2 (https://github.com/bcomnes/npm-run-all2/pull/142)
* fastify/fastify (https://github.com/fastify/fastify/pull/5509)
* nodejs/undici (https://github.com/nodejs/undici/pull/3485)
* poolifier/poolifier
* uuidjs/uuid` (https://github.com/uuidjs/uuid/pull/752)