ESLint Semistandard Style Config
`eslint-config-semistandard` provides an ESLint shareable configuration that enforces the JavaScript Semistandard Style. This style is a direct derivative of JavaScript Standard Style, with the key distinction of requiring semicolons at the end of statements, addressing a common preference among developers. Currently at version 17.0.0, the package maintains a close release cadence with `eslint-config-standard`, its upstream dependency, typically updating its major version whenever `eslint-config-standard` does. Its primary differentiator is this explicit support for semicolons, offering a pre-configured, opinionated linting setup for projects that value code consistency without the need to define a multitude of individual ESLint rules. This makes it an efficient choice for quick project setup while adhering to a widely recognized JavaScript style guide.
Common errors
-
Error: Failed to load config 'semistandard' to extend from.
cause The `eslint-config-semistandard` package is not installed or not resolvable by ESLint.fixEnsure `eslint-config-semistandard` is installed: `npm install --save-dev eslint-config-semistandard`. -
ESLint: The 'extends' property in your ESLint configuration specifies a configuration that is incompatible with your current ESLint version.
cause The installed ESLint version is not compatible with the `eslint-config-semistandard` or its base `eslint-config-standard` package's peer dependency requirements.fixCheck the `peerDependencies` of `eslint-config-semistandard` and `eslint-config-standard` (e.g., `npm info eslint-config-semistandard peerDependencies`) and install a compatible `eslint` version, typically `npm install --save-dev eslint@^8.13.0` for recent versions. -
ESLint: Rule 'promise/always-return' is not found.
cause One or more of the required ESLint plugins (e.g., `eslint-plugin-promise`, `eslint-plugin-import`, `eslint-plugin-n`) are missing or an incompatible version is installed.fixInstall all necessary peer dependencies at their specified versions: `npm install --save-dev eslint-plugin-import@^2.26.0 eslint-plugin-n@^15.0.0 eslint-plugin-promise@^6.0.0`.
Warnings
- breaking Version 16.0.0 was a breaking change, updating its base to `eslint-config-standard` version 16.x. Projects upgrading from older versions must also ensure their `eslint-config-standard` peer dependency is updated accordingly and review for any rule changes introduced by `standard`.
- breaking With version 16.0.0, the recommended ESLint configuration filename was changed from `.eslintrc.js` to `eslintrc.json` to align with `eslint-config-standard` practices. While `.eslintrc.js` might still work, using `.eslintrc.json` is the new standard.
- breaking Version 17.0.0 is based on `eslint-config-standard` version 17.0.0. This implies potential breaking changes or new rules inherited from the upstream `standard` configuration. All peer dependencies, especially `eslint-config-standard`, must be updated to their compatible major versions.
- gotcha This package, like many ESLint shareable configs, relies on several peer dependencies (e.g., `eslint`, `eslint-config-standard`, `eslint-plugin-import`). Failing to install these explicitly, or installing incompatible versions, will lead to errors.
Install
-
npm install eslint-config-semistandard -
yarn add eslint-config-semistandard -
pnpm add eslint-config-semistandard
Imports
- semistandard
import semistandard from 'eslint-config-semistandard';
{ "extends": "semistandard" }
Quickstart
npm install --save-dev eslint eslint-config-semistandard eslint-plugin-import eslint-plugin-n eslint-plugin-promise eslint-config-standard
// .eslintrc.json
{
"extends": "semistandard",
"env": {
"browser": true,
"node": true,
"es2021": true
}
}
// index.js (example file to lint)
const path = require('path');
const greet = (name) => {
console.log(`Hello, ${name}!`);
};
greet('World');
// Linting this file will enforce semicolon usage and other semistandard rules.
// For example, missing semicolons will be reported.
// To run: `npx eslint index.js`