{"id":13835405,"url":"https://github.com/standard/standard-engine","last_synced_at":"2025-04-08T12:09:04.570Z","repository":{"id":29487120,"uuid":"33024445","full_name":"standard/standard-engine","owner":"standard","description":":fire_engine: The guts of `standard` modularized for reuse","archived":false,"fork":false,"pushed_at":"2023-12-15T07:42:15.000Z","size":617,"stargazers_count":145,"open_issues_count":14,"forks_count":40,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-17T19:55:27.314Z","etag":null,"topics":["eslint","javascript","nodejs","standard","standard-engine","style"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/standard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["standard","feross"]}},"created_at":"2015-03-28T07:09:51.000Z","updated_at":"2025-03-12T20:42:20.000Z","dependencies_parsed_at":"2024-01-12T11:52:40.100Z","dependency_job_id":"5a50563e-ee7a-43c6-a079-fb936803c421","html_url":"https://github.com/standard/standard-engine","commit_stats":{"total_commits":863,"total_committers":58,"mean_commits":"14.879310344827585","dds":"0.30127462340672073","last_synced_commit":"cf701384c130889b9107efe3a0c26c586dca588c"},"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/standard%2Fstandard-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/standard%2Fstandard-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/standard%2Fstandard-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/standard%2Fstandard-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/standard","download_url":"https://codeload.github.com/standard/standard-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244102754,"owners_count":20398386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","javascript","nodejs","standard","standard-engine","style"],"created_at":"2024-08-04T14:01:01.241Z","updated_at":"2025-03-18T07:10:12.734Z","avatar_url":"https://github.com/standard.png","language":"JavaScript","readme":"# standard-engine [![Tests CI][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[ci-image]: https://github.com/standard/standard-engine/workflows/tests/badge.svg?branch=master\n[ci-url]: https://github.com/standard/standard-engine/actions?query=workflow%3A%22tests%22\n[npm-image]: https://img.shields.io/npm/v/standard-engine.svg\n[npm-url]: https://npmjs.org/package/standard-engine\n[downloads-image]: https://img.shields.io/npm/dm/standard-engine.svg\n[downloads-url]: https://npmjs.org/package/standard-engine\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n## Overview\n\nWrap your own eslint rules in a easy-to-use command line tool and/or a JS module.\n\n## Install\n\n```sh\nnpm install standard-engine\n```\n\n## Who is using `standard-engine`?\n\nHere is a list of packages using `standard-engine`. Dive into them for ideas!\n\n- [standard](https://standardjs.com) - JavaScript Standard Style.\n- [semistandard](https://github.com/standard/semistandard) - It's `standard` with semicolons sprinkled on top.\n- [standardx](https://github.com/standard/standardx) - JavaScript Standard Style with custom tweaks\n- [happiness](https://github.com/JedWatson/happiness) - JavaScript Happiness Style (semicolons and tabs)\n- [doublestandard](https://github.com/flet/doublestandard) - Require TWO semicolons at the end of every line!\n- [strict-standard](https://github.com/denis-sokolov/strict-standard) - Standard Style with strict error checking.\n- [standard-own](https://github.com/o2team/standard-own) - Standard configurable.\n- [ts-standard](https://github.com/standard/ts-standard) - TypeScript Standard Style.\n\nDid you make your own? Create a pull request and we will add it to the README!\n\n## Usage\n\nCreate the files below and fill in your own values for `options.js`.\n\n### `index.js`\n\n```js\n// programmatic usage\nconst { StandardEngine } = require('standard-engine')\nconst opts = require('./options.js')\nmodule.exports = new StandardEngine(opts)\n```\n\n### `cli.js`\n\n```js\n#!/usr/bin/env node\n\nconst opts = require('./options.js')\n\nrequire('standard-engine').cli(opts)\n```\n\n### `options.js`\n\n```js\nconst eslint = require('eslint')\nconst path = require('path')\nconst pkg = require('./package.json')\n\n/** @type {import('standard-engine').StandardEngineOptions} **/\nmodule.exports = {\n  // homepage, version and bugs pulled from package.json\n  version: pkg.version,\n  homepage: pkg.homepage,\n  bugs: pkg.bugs.url,\n  eslint, // pass any version of eslint \u003e= 7.0.0\n  cmd: 'pocketlint', // should match the \"bin\" key in your package.json\n  tagline: 'Live by your own standards!', // displayed in output --help\n  eslintConfig: {\n    overrideConfigFile: path.join(__dirname, 'eslintrc.json')\n  }\n}\n```\n\nAdditionally an optional `resolveEslintConfig()` function can be provided. See below for details.\n\n### `eslintrc.json`\n\nPut all your .eslintrc rules in this file. A good practice is to create an  [ESLint Shareable Config](http://eslint.org/docs/developer-guide/shareable-configs) and extend it, but its not required:\n\n```js\n{\n  // pretend that the package eslint-config-pocketlint exists!\n  \"extends\": [\"pocketlint\"]\n}\n```\n\nTake a look at [eslint-config-standard](https://github.com/feross/eslint-config-standard) as an example, or if you want to extend/mutate `standard`, see [eslint-config-semistandard](https://github.com/flet/eslint-config-semistandard).\n\n## Editor Integrations\n\nIntegrations and plugins should recognize the `standard-engine` tag in a\n`package.json` file. This allows end users to specify an arbitrary `standard-engine`\ncompatible linter that the plugin should use. The `standard-engine` tag can be a\nstring of the package:\n\n```json\n{\n  \"standard-engine\": \"pocketlint\"\n}\n```\n\nor an object with a `name` value of the package:\n\n```json\n{\n  \"standard-engine\": {\n    \"name\": \"pocketlint\"\n  }\n}\n```\n\n### Atom\n\n[linter-js-standard-engine][atom-plugin] is an Atom plugin that supports some of\nthe more popular standard-engine implementations out of the box. It detects them\nby scanning through the dependencies of the project that you are editing.\nYou can use it with any other implementation through configuration in the\nprojects `package.json` file.\n\n[atom-plugin]: https://github.com/gustavnikolaj/linter-js-standard-engine\n\n## Engine Features\n\n### Extensions\n\nThe extensions `.js`, `.jsx`, `.mjs`, and `.cjs` are linted by default. If you\npass directory paths to the `standardEngine.lintFiles()` method,\n`standard-engine` checks the files in those directories that have the given\nextensions.\n\nFor example, when passing the `src/` directory and the `extensions` option is\n`['.js', '.jsx']`, `standard-engine` will lint `*.js` and `*.jsx` files in\n`src/`.\n\nYou can disable these default ignores by setting the `noDefaultExensions` option to `true`.\n\n### Ignoring Files\n\nThe paths `node_modules/**`, `*.min.js`, `coverage/**`, hidden files/folders\n(beginning with `.`), and all patterns in a project's root `.gitignore` file are\nautomatically ignored.\n\nSometimes you need to ignore additional folders or specific minfied files. To do that, add\na `ignore` property to `package.json`:\n\n```js\n\"pocketlint\": { // this key should equal the value of cmd in options.js\n  \"ignore\": [\n    \"**/out/\",\n    \"/lib/select2/\",\n    \"/lib/ckeditor/\",\n    \"tmp.js\"\n  ]\n}\n```\n\nSome files are ignored by default:\n\n```js\nconst DEFAULT_IGNORE = [\n  '*.min.js',\n  'coverage/',\n  'node_modules/',\n  'vendor/'\n]\n```\n\nYou can disable these default ignores by setting the `noDefaultIgnore` option to `true`.\n\n### Hiding Warnings\n\nSince `standard-engine` uses [`eslint`](http://eslint.org/) under-the-hood, you can hide warnings as you normally would if you used `eslint` directly.\n\nDisable **all rules** on a specific line:\n\n```js\nfile = 'I know what I am doing' // eslint-disable-line\n```\n\nOr, disable **only** the `\"no-use-before-define\"` rule:\n\n```js\nfile = 'I know what I am doing' // eslint-disable-line no-use-before-define\n```\n\nOr, disable the `\"no-use-before-define\"` rule for **multiple lines**:\n\n```js\n/*eslint-disable no-use-before-define */\n// offending code here...\n// offending code here...\n// offending code here...\n/*eslint-enable no-use-before-define */\n```\n\n### Defining Globals in a project's `package.json`\n\n`standard-engine` will also look in a project's `package.json` and respect any global variables defined like so:\n\n```js\n{\n  \"pocketlint\": { // this key should equal the value of cmd in options.js\n    \"globals\": [ // can be a string or an array of strings\n      \"myVar1\",\n      \"myVar2\"\n    ]\n  }\n}\n```\n\nYou may use `global` as an alias for `globals` (just don't specify both).\n\n### Loading ESLint plugins in a project's `package.json`\n\nAdditional ESLint plugins can be specified like so:\n\n```js\n{\n  \"pocketlint\": { // this key should equal the value of cmd in options.js\n    \"plugins\": [ // can be a string or an array of strings\n      \"flowtype\"\n    ]\n  }\n}\n```\n\nYou may use `plugin` as an alias for `plugins` (just don't specify both). Plugins must be installed (example: `npm install eslint-plugin-flowtype` or globally: `npm install eslint-plugin-flowtype -g`).\n\n### Loading additional environments in a project's `package.json`\n\nAdditional environments can be specified like so:\n\n```js\n{\n  \"pocketlint\": { // this key should equal the value of cmd in options.js\n    \"envs\": [ \"browser\", \"mocha\" ]\n  }\n}\n```\n\n`envs` can be a string, an array of strings, or an object. In the latter case the keys are used as the environment name, but falsy values mean the environment is not actually loaded. You cannot unload environments by setting a falsy value.\n\nYou may use `env` as an alias for `envs` (just don't specify both).\n\n### Custom JS parsers for bleeding-edge ES6 or ES7 support?\n\n`standard-engine` supports custom JS parsers. To use a custom parser, install it from npm\n(example: `npm install babel-eslint`) and add this to your `package.json`:\n\n```js\n{\n  \"pocketlint\": { // this key should equal the value of cmd in your options.js\n    \"parser\": \"babel-eslint\"\n  }\n}\n```\n\nIf you're using your custom linter globally (you installed it with `-g`), then you also need to\ninstall `babel-eslint` globally with `npm install babel-eslint -g`.\n\n### Custom options\n\nYou can provide a `resolveEslintConfig()` function in the `options.js` exports:\n\n```js\nconst eslint = require('eslint')\nconst path = require('path')\nconst pkg = require('./package.json')\n\nmodule.exports = {\n  // homepage, version and bugs pulled from package.json\n  version: pkg.version,\n  homepage: pkg.homepage,\n  bugs: pkg.bugs.url,\n  eslint, // pass any version of eslint \u003e= 7.0.0\n  cmd: 'pocketlint', // should match the \"bin\" key in your package.json\n  tagline: 'Live by your own standards!', // displayed in output --help\n  eslintConfig: {\n    overrideConfigFile: path.join(__dirname, 'eslintrc.json')\n  },\n  resolveEslintConfig: function (eslintConfig, opts, packageOpts, rootDir) {\n    // provide implementation here, then return the eslintConfig object (or a new one)\n    return eslintConfig\n  }\n}\n```\n\nThis function is called with the current ESLint config (the options passed to the [`ESLint`](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) constructor), the options object (`opts`), any options extracted from the project's `package.json` (`packageOpts`), and the directory that contained that `package.json` file (`rootDir`, equivalent to `opts.cwd` if no file was found).\n\nModify and return `eslintConfig`, or return a new object with the eslint config to be used.\n\n## API Usage\n\n### `async engine.lintText(text, [opts])`\n\nLint the provided source `text` to enforce your defined style. An `opts` object may\nbe provided:\n\n```js\n{\n  // unique to lintText\n  filename: '',         // path of file containing the text being linted\n\n  // common to lintText and lintFiles\n  cwd: '',              // current working directory (default: process.cwd())\n  fix: false,           // automatically fix problems\n  extensions: [],       // file extensions to lint (has sane defaults)\n  globals: [],          // custom global variables to declare\n  plugins: [],          // custom eslint plugins\n  envs: [],             // custom eslint environment\n  parser: '',           // custom js parser (e.g. babel-eslint)\n  usePackageJson: true, // use options from nearest package.json?\n  useGitIgnore: true    // use file ignore patterns from .gitignore?\n}\n```\n\nAll options are optional, though some ESLint plugins require the `filename` option.\n\nAdditional options may be loaded from a `package.json` if it's found for the current working directory. See below for further details.\n\nReturns a `Promise` resolving to the `results` or rejected with an `Error`.\n\nThe `results` object will contain the following properties:\n\n```js\nconst results = {\n  results: [\n    {\n      filePath: '',\n      messages: [\n        { ruleId: '', message: '', line: 0, column: 0 }\n      ],\n      errorCount: 0,\n      warningCount: 0,\n      output: '' // fixed source code (only present with {fix: true} option)\n    }\n  ],\n  errorCount: 0,\n  warningCount: 0\n}\n```\n\n### `async engine.lintFiles(files, [opts])`\n\nLint the provided `files` globs. An `opts` object may be provided:\n\n```js\n{\n  // unique to lintFiles\n  ignore: [],           // file globs to ignore (has sane defaults)\n\n  // common to lintText and lintFiles\n  cwd: '',              // current working directory (default: process.cwd())\n  fix: false,           // automatically fix problems\n  extensions: [],       // file extensions to lint (has sane defaults)\n  globals: [],          // custom global variables to declare\n  plugins: [],          // custom eslint plugins\n  envs: [],             // custom eslint environment\n  parser: '',           // custom js parser (e.g. babel-eslint)\n  usePackageJson: true, // use options from nearest package.json?\n  useGitIgnore: true    // use file ignore patterns from .gitignore?\n}\n```\n\nAdditional options may be loaded from a `package.json` if it's found for the current working directory. See below for further details.\n\nBoth `ignore` and `files` patterns are resolved relative to the current working directory.\n\nReturns a `Promise` resolving to the `results` or rejected with an `Error` (same as above).\n\n**NOTE: There is no synchronous version of `engine.lintFiles()`.**\n\n### Full set of `opts`\n\nThis is the full set of options accepted by the above APIs. Not all options make sense for each API, for example `ignore` is not used with `lintText()`, and `filename` is not used with `lintFiles()`.\n\n```js\n{\n  ignore: [],   // file patterns to ignore (has sane defaults)\n  cwd: '',      // current working directory (default: process.cwd())\n  filename: '', // path of the file containing the text being linted (optional)\n  fix: false,   // automatically fix problems\n  globals: [],  // custom global variables to declare\n  plugins: [],  // custom eslint plugins\n  envs: [],     // custom eslint environment\n  parser: ''    // custom js parser (e.g. babel-eslint)\n}\n```\n\nThe following aliases are available:\n\n```js\n{\n  global: [],  // custom global variables to declare\n  plugin: [],  // custom eslint plugins\n  env: [],     // custom eslint environment\n}\n```\n\nNote that `globals`, `plugins` and `envs` take preference.\n\nThe `parser` option takes preference over any `parser` setting in the project's `package.json`.\n","funding_links":["https://github.com/sponsors/standard","https://github.com/sponsors/feross"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstandard%2Fstandard-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstandard%2Fstandard-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstandard%2Fstandard-engine/lists"}