{"id":12069,"library":"standard","title":"JavaScript Standard Style","description":"Standard is a JavaScript style guide, linter, and formatter designed for simplicity and consistency. It enforces a strict, opinionated code style with zero configuration, aiming to eliminate bike-shedding over stylistic choices. Currently at version 17.1.2, it sees active maintenance with minor releases frequently addressing dependency updates and bug fixes, while major versions, like v17.0.0, primarily focus on synchronizing with the broader ESLint ecosystem rather than introducing new rules. Key differentiators include its 'no configuration' philosophy, automatic code formatting via `standard --fix`, and early detection of style issues and common programmer errors, saving time in code reviews. It functions as an all-in-one alternative to separate tools like ESLint and Prettier, using ESLint under the hood but abstracting away its configuration complexity.","status":"active","version":"17.1.2","language":"javascript","source_language":"en","source_url":"git://github.com/standard/standard","tags":["javascript","JavaScript Standard Style","check","checker","code","code checker","code linter","code standards","code style"],"install":[{"cmd":"npm install standard","lang":"bash","label":"npm"},{"cmd":"yarn add standard","lang":"bash","label":"yarn"},{"cmd":"pnpm add standard","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Standard is primarily a command-line tool. It is not designed for direct module import for its core linting/fixing functionality. Use `npx` or a globally/locally installed `standard` binary.","wrong":"import standard from 'standard'","symbol":"standard (CLI)","correct":"npx standard --fix"},{"note":"For programmatic use in Node.js, specifically to lint a string of code, `lintText` can be imported. Ensure you're using ESM syntax if your project is ESM-first, otherwise `require` might work for older versions/setups.","wrong":"const standard = require('standard'); standard.lintText(...)","symbol":"lintText","correct":"import { lintText } from 'standard'"},{"note":"For programmatic use in Node.js to lint an array of file paths, `lintFiles` is available. As with `lintText`, favor ESM imports. These programmatic APIs are less commonly used than the CLI.","wrong":"const standard = require('standard'); standard.lintFiles(...)","symbol":"lintFiles","correct":"import { lintFiles } from 'standard'"}],"quickstart":{"code":"/* eslint-disable no-unused-vars */\nconst fs = require('fs')\n\nfunction exampleFunc(arg1) {;\n  var unusedVar = 10\n  const myString = \"hello world\"\n\n  if (arg1 == null) {\n    console.log(myString)\n  }\n}\n\n// Save this to a file like 'broken.js'\n// Then run 'npx standard broken.js --fix'\n// You can also add `\"test\": \"standard\"` to your package.json scripts and run `npm test`\n","lang":"javascript","description":"Demonstrates `standard`'s automatic fixing capabilities by showing a JavaScript file with common style violations (semicolons, var, ==, double quotes) and the command to fix them."},"warnings":[{"fix":"Review the changelog for v17.0.0 to identify specific rule changes. Update ESLint disable comments (e.g., change `node/` to `n/`). Run `standard --fix` to automatically resolve most stylistic issues after upgrading.","message":"Version 17.0.0 involved a full synchronization with ESLint 8. This included significant internal dependency updates (e.g., ESLint itself, `eslint-config-standard`, `eslint-plugin-react`), and notably, the replacement of `eslint-config-node` with `eslint-config-n`. This means previous ESLint disable comments like `// eslint-disable-line node/no-deprecated-api` must be updated to reference `n/` rules instead. The `object-shorthand` rule also changed to a warning by default, and `--verbose` output is now standard.","severity":"breaking","affected_versions":">=17.0.0"},{"fix":"Accept `standard`'s rules as-is. If customization is essential, migrate to direct ESLint usage and extend `eslint-config-standard` to layer your own changes, or consider `standardx` for minor tweaks.","message":"`standard` enforces a strict, opinionated style with 'zero configuration'. This means you cannot customize individual rules via a configuration file (e.g., `.eslintrc`). If you require fine-grained control over ESLint rules, you should use ESLint directly with `eslint-config-standard` as a base configuration, which defeats the purpose of using `standard` itself.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Choose one primary formatter/linter. If using `standard`, it's recommended to disable other formatters (e.g., Prettier) in your editor's workspace settings. If you need both, consider 'ejecting' from `standard` and using ESLint with `eslint-config-standard` and `eslint-config-prettier` to manage conflicts.","message":"Using `standard` alongside other formatters like Prettier can lead to conflicts due to differing formatting rules, resulting in inconsistent code and 'formatting wars'. StandardJS has specific opinions (e.g., no semicolons, single quotes) that may clash with Prettier's defaults or other configurations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your Node.js environment meets the minimum requirements (`^12.22.0 || ^14.17.0 || >=16.0.0`). Upgrade Node.js if necessary.","message":"Running `standard` on Node.js versions older than `^12.22.0 || ^14.17.0 || >=16.0.0` (as specified in `engines` field) might lead to silent failures or unexpected behavior due to the `version-guard` mechanism introduced in v17.1.0. While not an explicit error, it can prevent linting from running correctly without clear feedback.","severity":"deprecated","affected_versions":">=17.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `==` to `===` or `!=` to `!==`.","cause":"Using the loose equality operator (==) instead of the strict equality operator (===).","error":"Expected '===' and instead saw '=='."},{"fix":"Remove the unnecessary semicolon. `standard --fix` can often resolve these automatically.","cause":"`standard` enforces a 'no semicolons' rule where they are not strictly required.","error":"Extra semicolon."},{"fix":"Add a space: `function foo ()` instead of `function foo()` or `async () =>` instead of `async() =>`. `standard --fix` often corrects this.","cause":"Function declarations or expressions are missing a space between the function name (or keyword) and its opening parenthesis.","error":"Missing space before function parentheses."},{"fix":"Remove the unused variable or use it. If intentional, you might need to use `// eslint-disable-line no-unused-vars` (but this goes against `standard`'s philosophy).","cause":"A variable has been declared but its value is never read or referenced in the code.","error":"'someVar' is defined but never used."},{"fix":"Change `let` or `var` to `const` for variables that do not change their value. `standard --fix` can automate this.","cause":"A variable declared with `let` or `var` is not reassigned after its initial declaration.","error":"'someVar' is never reassigned. Use 'const' instead."}],"ecosystem":"npm"}