Git Product home page Git Product logo

standard-engine's Introduction

Standard - JavaScript Style Guide
JavaScript Standard Style

discord External tests Internal tests status badge old Node test npm version npm downloads Standard - JavaScript Style Guide

Sponsored by    Socket – Supply Chain Dependency Security for JavaScript and npm    Wormhole

EnglishEspañol (Latinoamérica)FrançaisBahasa IndonesiaItaliano (Italian)日本語 (Japanese)한국어 (Korean)Português (Brasil)简体中文 (Simplified Chinese)繁體中文 (Taiwanese Mandarin)

JavaScript style guide, linter, and formatter

This module saves you (and others!) time in three ways:

  • No configuration. The easiest way to enforce code quality in your project. No decisions to make. No .eslintrc files to manage. It just works.
  • Automatically format code. Just run standard --fix and say goodbye to messy or inconsistent code.
  • Catch style issues & programmer errors early. Save precious code review time by eliminating back-and-forth between reviewer & contributor.

Give it a try by running npx standard --fix right now!

Table of Contents

Install

The easiest way to use JavaScript Standard Style is to install it globally as a Node command line program. Run the following command in Terminal:

$ npm install standard --global

Or, you can install standard locally, for use in a single project:

$ npm install standard --save-dev

Note: To run the preceding commands, Node.js and npm must be installed.

Usage

After you've installed standard, you should be able to use the standard program. The simplest use case would be checking the style of all JavaScript files in the current working directory:

$ standard
Error: Use JavaScript Standard Style
  lib/torrent.js:950:11: Expected '===' and instead saw '=='.

If you've installed standard locally, run with npx instead:

$ npx standard

You can optionally pass in a directory (or directories) using the glob pattern. Be sure to quote paths containing glob patterns so that they are expanded by standard instead of your shell:

$ standard "src/util/**/*.js" "test/**/*.js"

Note: by default standard will look for all files matching the patterns: **/*.js, **/*.jsx.

What you might do if you're clever

  1. Add it to package.json

    {
      "name": "my-cool-package",
      "devDependencies": {
        "standard": "*"
      },
      "scripts": {
        "test": "standard && node my-tests.js"
      }
    }
  2. Style is checked automatically when you run npm test

    $ npm test
    Error: Use JavaScript Standard Style
      lib/torrent.js:950:11: Expected '===' and instead saw '=='.
  3. Never give style feedback on a pull request again!

Why should I use JavaScript Standard Style?

The beauty of JavaScript Standard Style is that it's simple. No one wants to maintain multiple hundred-line style configuration files for every module/project they work on. Enough of this madness!

This module saves you (and others!) time in three ways:

  • No configuration. The easiest way to enforce consistent style in your project. Just drop it in.
  • Automatically format code. Just run standard --fix and say goodbye to messy or inconsistent code.
  • Catch style issues & programmer errors early. Save precious code review time by eliminating back-and-forth between reviewer & contributor.

Adopting standard style means ranking the importance of code clarity and community conventions higher than personal style. This might not make sense for 100% of projects and development cultures, however open source can be a hostile place for newbies. Setting up clear, automated contributor expectations makes a project healthier.

For more info, see the conference talk "Write Perfect Code with Standard and ESLint". In this talk, you'll learn about linting, when to use standard versus eslint, and how prettier compares to standard.

Who uses JavaScript Standard Style?

Free MIDIs, MIDI file downloads College essays, AP notes
Your Logo Here

In addition to companies, many community members use standard on packages that are too numerous to list here.

standard is also the top-starred linter in GitHub's Clean Code Linter showcase.

Are there text editor plugins?

First, install standard. Then, install the appropriate plugin for your editor:

Sublime Text

Using Package Control, install SublimeLinter and SublimeLinter-contrib-standard.

For automatic formatting on save, install StandardFormat.

Atom

Install linter-js-standard.

Alternatively, you can install linter-js-standard-engine. Instead of bundling a version of standard it will automatically use the version installed in your current project. It will also work out of the box with other linters based on standard-engine.

For automatic formatting, install standard-formatter. For snippets, install standardjs-snippets.

Visual Studio Code

Install vscode-standard. (Includes support for automatic formatting.)

For JS snippets, install: vscode-standardjs-snippets. For React snippets, install vscode-react-standard.

Vim

Install ale. And add these lines to your .vimrc file.

let g:ale_linters = {
\   'javascript': ['standard'],
\}
let g:ale_fixers = {'javascript': ['standard']}

This sets standard as your only linter and fixer for javascript files and so prevents conflicts with eslint. For linting and automatic fixing on save, add these lines to .vimrc:

let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1

Alternative plugins to consider include neomake and syntastic, both of which have built-in support for standard (though configuration may be necessary).

Emacs

Install Flycheck and check out the manual to learn how to enable it in your projects.

Brackets

Search the extension registry for "Standard Code Style" and click "Install".

WebStorm (PhpStorm, IntelliJ, RubyMine, JetBrains, etc.)

WebStorm recently announced native support for standard directly in the IDE.

If you still prefer to configure standard manually, follow this guide. This applies to all JetBrains products, including PhpStorm, IntelliJ, RubyMine, etc.

Is there a readme badge?

Yes! If you use standard in your project, you can include one of these badges in your readme to let people know that your code is using the standard style.

JavaScript Style Guide

[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

JavaScript Style Guide

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

I disagree with rule X, can you change it?

No. The whole point of standard is to save you time by avoiding bikeshedding about code style. There are lots of debates online about tabs vs. spaces, etc. that will never be resolved. These debates just distract from getting stuff done. At the end of the day you have to 'just pick something', and that's the whole philosophy of standard -- its a bunch of sensible 'just pick something' opinions. Hopefully, users see the value in that over defending their own opinions.

There are a couple of similar packages for anyone who does not want to completely accept standard:

If you really want to configure hundreds of ESLint rules individually, you can always use eslint directly with eslint-config-standard to layer your changes on top. standard-eject can help you migrate from standard to eslint and eslint-config-standard.

Pro tip: Just use standard and move on. There are actual real problems that you could spend your time solving! :P

But this isn't a real web standard!

Of course it's not! The style laid out here is not affiliated with any official web standards groups, which is why this repo is called standard/standard and not ECMA/standard.

The word "standard" has more meanings than just "web standard" :-) For example:

  • This module helps hold our code to a high standard of quality.
  • This module ensures that new contributors follow some basic style standards.

Is there an automatic formatter?

Yes! You can use standard --fix to fix most issues automatically.

standard --fix is built into standard for maximum convenience. Most problems are fixable, but some errors (like forgetting to handle errors) must be fixed manually.

To save you time, standard outputs the message "Run standard --fix to automatically fix some problems" when it detects problems that can be fixed automatically.

How do I ignore files?

Certain paths (node_modules/, coverage/, vendor/, *.min.js, and files/folders that begin with . like .git/) are automatically ignored.

Paths in a project's root .gitignore file are also automatically ignored.

Sometimes you need to ignore additional folders or specific minified files. To do that, add a standard.ignore property to package.json:

"standard": {
  "ignore": [
    "**/out/",
    "/lib/select2/",
    "/lib/ckeditor/",
    "tmp.js"
  ]
}

How do I disable a rule?

In rare cases, you'll need to break a rule and hide the error generated by standard.

JavaScript Standard Style uses ESLint under-the-hood and you can hide errors as you normally would if you used ESLint directly.

Disable all rules on a specific line:

file = 'I know what I am doing' // eslint-disable-line

Or, disable only the "no-use-before-define" rule:

file = 'I know what I am doing' // eslint-disable-line no-use-before-define

Or, disable the "no-use-before-define" rule for multiple lines:

/* eslint-disable no-use-before-define */
console.log('offending code goes here...')
console.log('offending code goes here...')
console.log('offending code goes here...')
/* eslint-enable no-use-before-define */

I use a library that pollutes the global namespace. How do I prevent "variable is not defined" errors?

Some packages (e.g. mocha) put their functions (e.g. describe, it) on the global object (poor form!). Since these functions are not defined or require'd anywhere in your code, standard will warn that you're using a variable that is not defined (usually, this rule is really useful for catching typos!). But we want to disable it for these global variables.

To let standard (as well as humans reading your code) know that certain variables are global in your code, add this to the top of your file:

/* global myVar1, myVar2 */

If you have hundreds of files, it may be desirable to avoid adding comments to every file. In this case, run:

$ standard --global myVar1 --global myVar2

Or, add this to package.json:

{
  "standard": {
    "globals": [ "myVar1", "myVar2" ]
  }
}

Note: global and globals are equivalent.

How do I use experimental JavaScript (ES Next) features?

standard supports the latest ECMAScript features, ES8 (ES2017), including language feature proposals that are in "Stage 4" of the proposal process.

To support experimental language features, standard supports specifying a custom JavaScript parser. Before using a custom parser, consider whether the added complexity is worth it.

To use a custom parser, first install it from npm:

npm install @babel/eslint-parser --save-dev

Then run:

$ standard --parser @babel/eslint-parser

Or, add this to package.json:

{
  "standard": {
    "parser": "@babel/eslint-parser"
  }
}

Can I use a JavaScript language variant, like Flow or TypeScript?

standard supports the latest ECMAScript features. However, Flow and TypeScript add new syntax to the language, so they are not supported out-of-the-box.

For TypeScript, an official variant ts-standard is supported and maintained that provides a very similar experience to standard.

For other JavaScript language variants, standard supports specifying a custom JavaScript parser as well as an ESLint plugin to handle the changed syntax. Before using a JavaScript language variant, consider whether the added complexity is worth it.

TypeScript

ts-standard is the officially supported variant for TypeScript. ts-standard supports all the same rules and options as standard and includes additional TypeScript specific rules. ts-standard will even lint regular javascript files by setting the configuration in tsconfig.json.

npm install ts-standard --save-dev

Then run (where tsconfig.json is located in the working directory):

$ ts-standard

Or, add this to package.json:

{
  "ts-standard": {
    "project": "./tsconfig.json"
  }
}

Note: To include additional files in linting such as test files, create a tsconfig.eslint.json file to use instead.

If you really want to configure hundreds of ESLint rules individually, you can always use eslint directly with eslint-config-standard-with-typescript to layer your changes on top.

Flow

To use Flow, you need to run standard with @babel/eslint-parser as the parser and eslint-plugin-flowtype as a plugin.

npm install @babel/eslint-parser eslint-plugin-flowtype --save-dev

Then run:

$ standard --parser @babel/eslint-parser --plugin flowtype

Or, add this to package.json:

{
  "standard": {
    "parser": "@babel/eslint-parser",
    "plugins": [ "flowtype" ]
  }
}

Note: plugin and plugins are equivalent.

What about Mocha, Jest, Jasmine, QUnit, etc?

To support mocha in test files, add this to the top of the test files:

/* eslint-env mocha */

Or, run:

$ standard --env mocha

Where mocha can be one of jest, jasmine, qunit, phantomjs, and so on. To see a full list, check ESLint's specifying environments documentation. For a list of what globals are available for these environments, check the globals npm module.

Note: env and envs are equivalent.

What about Web Workers and Service Workers?

Add this to the top of web worker files:

/* eslint-env worker */

This lets standard (as well as humans reading the code) know that self is a global in web worker code.

For Service workers, add this instead:

/* eslint-env serviceworker */

What is the difference between warnings and errors?

standard treats all rule violations as errors, which means that standard will exit with a non-zero (error) exit code.

However, we may occasionally release a new major version of standard which changes a rule that affects the majority of standard users (for example, transitioning from var to let/const). We do this only when we think the advantage is worth the cost and only when the rule is auto-fixable.

In these situations, we have a "transition period" where the rule change is only a "warning". Warnings don't cause standard to return a non-zero (error) exit code. However, a warning message will still print to the console. During the transition period, using standard --fix will update your code so that it's ready for the next major version.

The slow and careful approach is what we strive for with standard. We're generally extremely conservative in enforcing the usage of new language features. We want using standard to be light and fun and so we're careful about making changes that may get in your way. As always, you can disable a rule at any time, if necessary.

Can I check code inside of Markdown or HTML files?

To check code inside Markdown files, use standard-markdown.

Alternatively, there are ESLint plugins that can check code inside Markdown, HTML, and many other types of language files:

To check code inside Markdown files, use an ESLint plugin:

$ npm install eslint-plugin-markdown

Then, to check JS that appears inside code blocks, run:

$ standard --plugin markdown '**/*.md'

To check code inside HTML files, use an ESLint plugin:

$ npm install eslint-plugin-html

Then, to check JS that appears inside <script> tags, run:

$ standard --plugin html '**/*.html'

Is there a Git pre-commit hook?

Yes! Hooks are great for ensuring that unstyled code never even makes it into your repo. Never give style feedback on a pull request again!

You even have a choice...

Install your own hook

#!/bin/bash

# Ensure all JavaScript files staged for commit pass standard code style
function xargs-r() {
  # Portable version of "xargs -r". The -r flag is a GNU extension that
  # prevents xargs from running if there are no input files.
  if IFS= read -r -d $'\n' path; then
    echo "$path" | cat - | xargs "$@"
  fi
}
git diff --name-only --cached --relative | grep '\.jsx\?$' | sed 's/[^[:alnum:]]/\\&/g' | xargs-r -E '' -t standard
if [[ $? -ne 0 ]]; then
  echo 'JavaScript Standard Style errors were detected. Aborting commit.'
  exit 1
fi

Use a pre-commit hook

The pre-commit library allows hooks to be declared within a .pre-commit-config.yaml configuration file in the repo, and therefore more easily maintained across a team.

Users of pre-commit can simply add standard to their .pre-commit-config.yaml file, which will automatically fix .js, .jsx, .mjs and .cjs files:

  - repo: https://github.com/standard/standard
    rev: master
    hooks:
      - id: standard

Alternatively, for more advanced styling configurations, use standard within the eslint hook:

  - repo: https://github.com/pre-commit/mirrors-eslint
    rev: master
    hooks:
      - id: eslint
        files: \.[jt]sx?$  # *.js, *.jsx, *.ts and *.tsx
        types: [file]
        additional_dependencies:
          - eslint@latest
          - eslint-config-standard@latest
          # and whatever other plugins...

How do I make the output all colorful and pretty?

The built-in output is simple and straightforward, but if you like shiny things, install snazzy:

$ npm install snazzy

And run:

$ standard | snazzy

There's also standard-tap, standard-json, standard-reporter, and standard-summary.

Is there a Node.js API?

Yes!

async standard.lintText(text, [opts])

Lint the provided source text. An opts object may be provided:

{
  // unique to lintText
  filename: '',         // path of file containing the text being linted

  // common to lintText and lintFiles
  cwd: '',              // current working directory (default: process.cwd())
  fix: false,           // automatically fix problems
  extensions: [],       // file extensions to lint (has sane defaults)
  globals: [],          // custom global variables to declare
  plugins: [],          // custom eslint plugins
  envs: [],             // custom eslint environment
  parser: '',           // custom js parser (e.g. babel-eslint)
  usePackageJson: true, // use options from nearest package.json?
  useGitIgnore: true    // use file ignore patterns from .gitignore?
}

All options are optional, though some ESLint plugins require the filename option.

Additional options may be loaded from a package.json if it's found for the current working directory. See below for further details.

Returns a Promise resolving to the results or rejected with an Error.

The results object will contain the following properties:

const results = {
  results: [
    {
      filePath: '',
      messages: [
        { ruleId: '', message: '', line: 0, column: 0 }
      ],
      errorCount: 0,
      warningCount: 0,
      output: '' // fixed source code (only present with {fix: true} option)
    }
  ],
  errorCount: 0,
  warningCount: 0
}

async standard.lintFiles(files, [opts])

Lint the provided files globs. An opts object may be provided:

{
  // unique to lintFiles
  ignore: [],           // file globs to ignore (has sane defaults)

  // common to lintText and lintFiles
  cwd: '',              // current working directory (default: process.cwd())
  fix: false,           // automatically fix problems
  extensions: [],       // file extensions to lint (has sane defaults)
  globals: [],          // custom global variables to declare
  plugins: [],          // custom eslint plugins
  envs: [],             // custom eslint environment
  parser: '',           // custom js parser (e.g. babel-eslint)
  usePackageJson: true, // use options from nearest package.json?
  useGitIgnore: true    // use file ignore patterns from .gitignore?
}

Additional options may be loaded from a package.json if it's found for the current working directory. See below for further details.

Both ignore and files patterns are resolved relative to the current working directory.

Returns a Promise resolving to the results or rejected with an Error (same as above).

How do I contribute to StandardJS?

Contributions are welcome! Check out the issues or the PRs, and make your own if you want something that you don't see there.

Want to chat? Join contributors on Discord.

Here are some important packages in the standard ecosystem:

There are also many editor plugins, a list of npm packages that use standard, and an awesome list of packages in the standard ecosystem.

Security Policies and Procedures

The standard team and community take all security bugs in standard seriously. Please see our security policies and procedures document to learn how to report issues.

License

MIT. Copyright (c) Feross Aboukhadijeh.

standard-engine's People

Contributors

achingbrain avatar brandonhorst avatar dcousens avatar denis-sokolov avatar dependabot[bot] avatar dziemba avatar feross avatar flet avatar fskreuz avatar greenkeeper[bot] avatar greenkeeperio-bot avatar gustavnikolaj avatar jasonkarns avatar linusu avatar lvillani avatar madhavarshney avatar mafintosh avatar max-mapper avatar mightyiam avatar novemberborn avatar ricardofbarros avatar romkhub avatar rostislav-simonik avatar rstacruz avatar santiagogil avatar theoludwig avatar ungoldman avatar voxpelli avatar wombleton avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

standard-engine's Issues

Tests are failing and possibly lintText method is not working

Error: Cannot find module 'eslint-config-standard'
Referenced from: /Users/rbarros/Desktop/github/standard-engine/node_modules/standard/rc/.eslintrc
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at loadConfig (/Users/rbarros/Desktop/github/standard-engine/node_modules/eslint/lib/config.js:91:34)
    at loadConfig (/Users/rbarros/Desktop/github/standard-engine/node_modules/eslint/lib/config.js:114:44)
    at new Config (/Users/rbarros/Desktop/github/standard-engine/node_modules/eslint/lib/config.js:329:34)
    at CLIEngine.executeOnFiles (/Users/rbarros/Desktop/github/standard-engine/node_modules/eslint/lib/cli-engine.js:318:28)
    at /Users/rbarros/Desktop/github/standard-engine/node_modules/standard/index.js:105:52
    at zalgoSafe (/Users/rbarros/Desktop/github/standard-engine/node_modules/dezalgo/dezalgo.js:20:10)

This could be easily fixed adding eslint-config-standard to dependencies.

Support additional option parsing

I'd like to support additional options in my linter. I'd need access to the packageOpts. Perhaps a parser function could be provided when creating the linter, and called with the opts and packageOpts when options are parsed.

I can do a PR for this if you're interested.

An in-range update of eslint-config-standard is breaking the build 🚨

Version 11.0.0 of eslint-config-standard was just published.

Branch Build failing 🚨
Dependency eslint-config-standard
Current Version 11.0.0-beta.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-standard is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 10 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Provide greater flexibility in command-line configurations

standard-engine feels great when configured for one project. I would like to integrate standard-engine as a baseline configuration for many projects. I am running into issues with being able to configure simple things like cwd, ignorePath, etc... on the fly (i.e. command-line parameters).

One area that can be improved would be the customizable parseOpts function by allowing non-standard flags to be passed in. Currently argv._ assumes all inputs are files, it would be nice if there is a way to parse out custom parameters that can be used in the parseOpts method.

Please let me know your thoughts, I would be willing to contribute.

Using eslintrc from the project

standard/standard#351 (comment)

It'd be nice for standard-engine to pick up your local .eslintrc. You can set your eslintrc to this, and customize it as you see fit.

{
  "extends": ["standard", "standard-react"]
}

Rationale:

  • be able to use (or not use) standard-react (ouch)
  • be able to use semistandard (or similar)
  • you can disable rules if you really really want to
  • use standard-engine (which is much better than eslint's own CLI, imho!) with other eslint rules
  • use tape-standard, mocha-standard and similar with other eslint rules

As a bonus, maybe it can be defined in package.json as an alternative (much like babel lets you define options in .babelrc and package.json/babel)

An in-range update of eslint is breaking the build 🚨

Version 5.0.0 of eslint was just published.

Branch Build failing 🚨
Dependency [eslint](https://github.com/eslint/eslint)
Current Version 4.19.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v5.0.0

Release blogpost

Migration guide

  • 0feedfd New: Added max-lines-per-function rule (fixes #9842) (#10188) (peteward44)
  • daefbdb Upgrade: eslint-scope and espree to 4.0.0 (refs #10458) (#10500) (Brandon Mills)
  • 077358b Docs: no-process-exit: recommend process.exitCode (#10478) (Andres Kalle)
  • f93d6ff Fix: do not fail on unknown operators from custom parsers (fixes #10475) (#10476) (Rubén Norte)
  • 05343fd Fix: add parens for yield statement (fixes #10432) (#10468) (Pig Fang)
  • d477c5e Fix: check destructuring for "no-shadow-restricted-names" (fixes #10467) (#10470) (Pig Fang)
  • 7a7580b Update: Add considerPropertyDescriptor option to func-name-matching (#9078) (Dieter Luypaert)
  • e0a0418 Fix: crash on optional catch binding (#10429) (Toru Nagashima)
  • de4dba9 Docs: styling team members (#10460) (薛定谔的猫)
  • 5e453a3 Docs: display team members in tables. (#10433) (薛定谔的猫)
  • b1895eb Docs: Restore intentional spelling mistake (#10459) (Wilfred Hughes)
Commits

The new version differs by 148 commits.

  • 36ced0a 5.0.0
  • 5fd5632 Build: changelog update for 5.0.0
  • 0feedfd New: Added max-lines-per-function rule (fixes #9842) (#10188)
  • daefbdb Upgrade: eslint-scope and espree to 4.0.0 (refs #10458) (#10500)
  • 077358b Docs: no-process-exit: recommend process.exitCode (#10478)
  • f93d6ff Fix: do not fail on unknown operators from custom parsers (fixes #10475) (#10476)
  • 05343fd Fix: add parens for yield statement (fixes #10432) (#10468)
  • d477c5e Fix: check destructuring for "no-shadow-restricted-names" (fixes #10467) (#10470)
  • 7a7580b Update: Add considerPropertyDescriptor option to func-name-matching (#9078)
  • e0a0418 Fix: crash on optional catch binding (#10429)
  • de4dba9 Docs: styling team members (#10460)
  • 5e453a3 Docs: display team members in tables. (#10433)
  • b1895eb Docs: Restore intentional spelling mistake (#10459)
  • a9da57d 5.0.0-rc.0
  • 3ac3df6 Build: changelog update for 5.0.0-rc.0

There are 148 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Should not print lint errors when formatting stdin

Example

fibonacci.js

module.exports = fibonacci

function fibonacci (n) {
  var a = 0, b = 1, f = 1;
  for (var i = 2; i <= n; i++) {
      f = a + b;
      a = b;
      b = f;
  }
  return f;
}

Run standard format w/ stdin option on file:

cat fibonacci.js | standard --format --stdin

Prints:

module.exports = fibonacci

function fibonacci (n) {
  var a = 0, b = 1, f = 1
  for (var i = 2; i <= n; i++) {
    f = a + b
    a = b
    b = f
  }
  return f
}
standard: Use JavaScript Standard Style (https://github.com/feross/standard)
standard:   <text>:4:3: Split initialized 'var' declarations into multiple statements.

I would expect to be able to do the following:

cat fibonacci.js | standard --format --stdin > fibonacci-formatted.js

However, this would result in a invalid javascript file (bc the lint warnings would be appended to the bottom of the file)

Basic complete usage example.

What is the minimal set up to get basic standard-linting within node.js?

When I use a new Linter({eslint, eslintConfig: {"extends": ["standard"]}}) to lintTextSync some non-standard String, I get

{ results: 
   [ { filePath: '<text>',
       messages: [],
       errorCount: 0,
       warningCount: 0 } ],
  errorCount: 0,
  warningCount: 0 }

How do I get standard to show me that something is wrong with my code?

An in-range update of eslint-config-standard-jsx is breaking the build 🚨

Version 6.0.0 of eslint-config-standard-jsx was just published.

Branch Build failing 🚨
Dependency eslint-config-standard-jsx
Current Version 5.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-standard-jsx is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 11 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add ability to pass in a formatter for the CLI

Formattet should expose a transform function which we would call from the CLI if -F or --format is passed.

@ricardofbarros:

But the API of the maxodgen/standard-formatter is pretty simple and straightforward, 2 methods .load(opts, cb) and .transform(file), in which the standard-engine only will be using transform, so for compatibility of the formatter API we should only check for 1 method.

Add CLI flag to disable tagline output

Could a flag (e.g. --quiet) be added to disable the following?

standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.

I realise this could be done with e.g. standard 2>/dev/null, but then other errors would be silenced.

An in-range update of tape is breaking the build 🚨

Version 4.9.0 of tape was just published.

Branch Build failing 🚨
Dependency tape
Current Version 4.8.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

tape is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 27 commits.

  • ea6d91e v4.9.0
  • 6867840 [Deps] update object-inspect, resolve
  • 4919e40 [Tests] on node v9; use nvm install-latest-npm
  • f26375c Merge pull request #420 from inadarei/global-depth-env-var
  • 17276d7 [New] use process.env.NODE_TAPE_OBJECT_PRINT_DEPTH for the default object print depth.
  • 0e870c6 Merge pull request #408 from johnhenry/feature/on-failure
  • 00aa133 Add "onFinish" listener to test harness.
  • 0e68b2d [Dev Deps] update js-yaml
  • 10b7dcd [Fix] fix stack where actual is falsy
  • 13173a5 Merge pull request #402 from nhamer/stack_strip
  • f90e487 normalize path separators in stacks
  • b66f8f8 [Deps] update function-bind
  • cc69501 Merge pull request #387 from fongandrew/master
  • bf5a750 Handle spaces in path name for setting file, line no
  • 3c2087a Test name with spaces

There are 27 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Linter is not producing warnings

Given the following:

const standard = require('.').linter({eslint: require('eslint')})
standard.lintText('var a = 1;', function(err, res) { console.dir(res) })

I would expect to see something about an unneeded semicolon, but instead the result is:

{ results: 
   [ { filePath: '<text>',
       messages: [],
       errorCount: 0,
       warningCount: 0 } ],
  errorCount: 0,
  warningCount: 0 }

Am I doing it wrong?

Atom plugin for standard-engine linters.

@novemberborn and I have been at work creating an Atom linter plugin for standard-engine based linters (GitHub repo).

It supports a few popular standard-engine implementations out of the box, but can support any compatible linter through configuration in the projects package.json file. The main selling point of this specific plugin, besides that it is working for any standard-engine based linter, is that it will run the version installed in your project and does not bundle a few specific versions into itself.

I see that you don't have any editor specific integrations listed, which makes sense as this project is not targeting "end-users", but I thought that it might be useful to add a note here for any other people that maintain big or small standard-engine linters. Either just through this issue, or maybe even as a note in the README file. I would love to send a PR if it's anything you'd be interested in. :-)

The heading of error reports have a hardcoded "Use " string added.

When using standard:

$ standard foo.js
standard: Use JavaScript Standard Style (https://github.com/feross/standard) 
  /home/usernme/foo.js:1:33: Extra semicolon.

This is the code that generates the line: https://github.com/Flet/standard-engine/blob/581a4f081f9b3348f5389629543dec2e2bb94e6d/bin/cmd.js#L119-L123

The tagline of standard is "JavaScript Standard Style" - why is the Use appended?

I wanted to use standard-engine to replace an old lint setup at work. My chosen tag line does not go well with "Use" prepended to it.

Why was it chosen to hardcode part of the string? Will you be open to a pull request removing it? :-)

Unused file

I think the file bin/standard-engine-cmd.js isn't currently being used by anything.

Override files list with globs

I'm trying to override the files list, to include bin scripts. I'd like to use ['**/*.js', '**/*.jsx', 'bin/*'], but the globs get expanded before they ever get here (by bash I assume). Which means what is matched is significantly different from what the glob module would match (and varies per the user's bash profile).

Maybe this is an issue with how to format the files string for glob, but I cannot get any variation of standard **/*.js **/*.jsx bin/* to work (no matter how I format or escape it. Any thoughts?

Standardize a package.json line for linter forks

Right now we have a lot of plugins built around standard (and standard-engine). Sadly, most of these plugins use a hard coded list of forks for customizing. This makes it extremely hard to use a company or personal fork of standard, but still have all of the plugin support we love.

Standard engine should document a package.json key to identify a standard-engine compatible linting package. linter-js-standard-engine already documents a standard-engine key that is refered to in this project's readme, so I recommend just taking that and putting it in the standard-engine README.md.

add option/flag to invoke eslint's --fix feature

Passing through a --fix flag/option to eslint might be a nice, lightweight alternative to using a full formatter like standard-format without adding any additional dependencies,

Looking at standard, about 25% of the rules are covered by --fix currently:

arrow-spacing: enforce consistent spacing before and after the arrow in arrow functions 
block-spacing: enforce consistent spacing inside single-line blocks 
comma-dangle: require or disallow trailing commas  
comma-spacing: enforce consistent spacing before and after commas 
eol-last: enforce at least one newline at the end of files 
generator-star-spacing: enforce consistent spacing around * operators in generator functions 
indent: enforce consistent indentation 
jsx-quotes: enforce the consistent use of either double or single quotes in JSX attributes 
keyword-spacing: enforce consistent spacing before and after keywords 
no-multi-spaces: disallow multiple spaces 
no-spaced-func: disallow spacing between function identifiers and their applications 
no-trailing-spaces: disallow trailing whitespace at the end of lines 
no-whitespace-before-property: disallow whitespace before properties 
quotes: enforce the consistent use of either backticks, double, or single quotes 
semi-spacing: enforce consistent spacing before and after semicolons 
semi: require or disallow semicolons instead of ASI 
space-before-blocks: enforce consistent spacing before blocks 
space-before-function-paren: enforce consistent spacing before function definition opening parenthesis 
space-in-parens: enforce consistent spacing inside parentheses 
space-infix-ops: require spacing around operators 
space-unary-ops: enforce consistent spacing before or after unary operators 
spaced-comment: enforce consistent spacing after the // or /* in a comment 
template-curly-spacing: require or disallow spacing around embedded expressions of template strings 
yield-star-spacing: require or disallow spacing around the * in yield* expressions

This is a lot more rules than last time I checked!

I'd like to see standard-engine expose a --fix flag via the CLI as well as opts.fix for programmatic usage.

Thoughts?

Support filename in lintText?

It'd be cool if lintText() could support a filename argument, to be forwarded to executeOnText. For backwards compatibility reasons it could be a fourth argument, after cb.

I can make this change if you're interested.

(More ambitiously, perhaps breaking changes could be made along the board.)

Installation fails on Node 0.10

All my Travis tests on Node 0.10 have been failing since yesterday (example) because npm 1.4.28 is unable to install the dependency on "https://github.com/eslint/eslint.git#9d6223040316456557e0a2383afd96be90d28c5a". It raises a pretty cryptic "not a package" error on the download.

I can reproduce this on my Windows machine if I install those same versions and install standard-engine, so I guess there's a syntax issue. As per the docs, I think abbreviating the URL to "eslint/eslint#9d6223040316456557e0a2383afd96be90d28c5a" would make it more compatible.

.lintText() strange behaviour

The node API has a different outcome from the CLI.

For instance, take this piece of code as proof of this strange behaviour:

function test () {
  try{
  } catch(e) {
    return 1;
  }
}

If I run the semistandard's CLI I get the following errors:

semistandard: Use Semicolons For All! (https://github.com/Flet/semistandard)
  /Users/rbarros/Desktop/github/linter-js-standard/test.js:1:10: "test" is defined but never used (no-unused-vars)
  /Users/rbarros/Desktop/github/linter-js-standard/test.js:2:3: Keyword "try" must be followed by whitespace. (space-after-keywords)
  /Users/rbarros/Desktop/github/linter-js-standard/test.js:2:6: Missing space before opening brace. (space-before-blocks)
  /Users/rbarros/Desktop/github/linter-js-standard/test.js:3:5: Keyword "catch" must be followed by whitespace. (space-after-keywords)

But If I run the .lintText() I get this:

[ { filePath: '<text>',
    messages:
     [ { ruleId: 'no-unused-vars',
         severity: 2,
         message: '"test" is defined but never used',
         line: 1,
         column: 10,
         nodeType: 'Identifier',
         source: 'function test () {' },
       { ruleId: 'space-after-keywords',
         severity: 2,
         message: 'Keyword "try" must be followed by whitespace.',
         line: 2,
         column: 3,
         nodeType: 'TryStatement',
         source: '  try{' },
       { ruleId: 'space-before-blocks',
         severity: 2,
         message: 'Missing space before opening brace.',
         line: 2,
         column: 6,
         nodeType: 'BlockStatement',
         source: '  try{' } ],
    errorCount: 3,
    warningCount: 0 } ]

Only 3 errors instead of the expected 4 errors. This issue was found out by @JGAntunes

node.js API - lintText() code:

var semistandard = require('semistandard')
var fs = require('fs')
var util = require('util')

semistandard.lintText(fs.readFileSync('./test.js', 'utf-8'), function (err, res) {
  console.log(util.inspect(res.results, {showHidden: false, depth: null}))
})

An in-range update of eslint-plugin-react is breaking the build 🚨

Version 7.10.0 of eslint-plugin-react was just published.

Branch Build failing 🚨
Dependency [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react)
Current Version 7.9.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 23 commits.

  • 157cc93 Update CHANGELOG and bump version
  • 7c5a16f [Deps] update has, prop-types
  • 93ce3c5 [Dev Deps] update babel-eslint
  • 5186b16 Merge pull request #1845 from alexzherdev/1844-no-set-state-unsafe-will-update
  • 8122c8b Account for UNSAFE_ method in no-will-update-set-state
  • c6cc4ab [New] Allow eslint ^5
  • 4121b59 [Tests] clean up test matrix
  • 7869530 Merge pull request #1831 from sergei-startsev/no-unsafe-rule
  • 0285eef Excluded no-unsafe from the recommended for now to avoid breaking changes
  • e41500a Added early termination for no-unsafe, adjusted tests to support ESLint3
  • 5e17159 Added missed position details for no-unsafe
  • 5b08a1e Adjusted no-unsafe rule
  • b5e86bf Added no-unsafe rule
  • 48e386d Merge pull request #1827 from alexzherdev/1677-no-typos-static-proptypes
  • d68b9e8 Remove unnecessary babel-eslint and fix typo

There are 23 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Specifying parserOptions for ESLint

standard-engine supports custom parsers (e.g. babel-eslint), but it would also be nice if it allowed us to set the parser options in ESLint's default parser. My particular use case is enabling standard ES7 features so I can use the exponentiation operator:

{
    "parserOptions": {
        "ecmaVersion": 7
    }
}

Thanks for your work on this project, by the way!

An in-range update of eslint-plugin-import is breaking the build 🚨

Version 2.13.0 of eslint-plugin-import was just published.

Branch Build failing 🚨
Dependency [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import)
Current Version 2.12.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 7 commits.

  • c34f14f changelog/package bumps
  • 9db789b [Fix] namespace: ensure this rule works in ES2018
  • add69cf [New] Add ESLint 5 support
  • 59fc04e [Tests] on node v10
  • cdb328c [webpack] log a useful error in a module bug arises
  • ebafcbf no-restricted-paths: complete coverage
  • e6f5c13 No relative parent imports rule (#1093)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Better README

Need to pull the pertinent parts of the standard README into this repository. Specifically some of the FAQs and other engine-specific parts.

An in-range update of babel-eslint is breaking the build 🚨

Version 8.2.5 of babel-eslint was just published.

Branch Build failing 🚨
Dependency [babel-eslint](https://github.com/babel/babel-eslint)
Current Version 8.2.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

babel-eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

glob for ignore files from CLI

by default some common files will be ignored, but this functionality is not exposed in the CLI for add more files to be ignored (or I didn't found documentation about that).

Include snazzy in package

hi there, I saw the great talk by feross on using standard-engine to wrap our eslint configs. i see that snazzy is a separate tool used to make the output look nice. Is there a way to include the snazzy output with our custom CLI created from standard-engine, or would it be necessary to make some code changes? it would be nice to not have to install two packages everytime you want to lint.

And thanks for this cool package

An in-range update of standard is breaking the build 🚨

Version 11.0.0 of standard was just published.

Branch Build failing 🚨
Dependency standard
Current Version 10.0.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

standard is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 50 commits.

There are 50 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Allow useEslintrc for cascading overrides

standard-engine current disables eslint's support for .eslintrc files. I realize this was probably done to simplify configuration and prevent bikeshedding, but I did some research on how .eslintrc files cascade and it seems like it would be useful to prevent configuration duplication with standard-engine.

For example, I'm working on a project using the standard code style and I have some settings I want to apply to all of my test files, but nothing else. With standard (which of course, uses standard-engine), I would either have to set options in package.json (which is global to my project, and covers too many files) or set comments in every test file. I would prefer to use a single .eslintrc file in the root of my test directory to override rules for these settings (I believe eslint itself supports this out of the box). I figure this functionality would be useful for other end users of packages that consume standard-engine.

See Configuration Cascading and Hierarchy.

Use a default eslint and eslintConfig

The linter constructor doesn't seem to work without options:

❯ trymodule standard-engine
Package 'standard-engine' was loaded and assigned to 'standard_engine' in the current scope
REPL started...
> standard_engine
{ cli: [Function: Cli], linter: [Function: Linter] }

> const standard = standard_engine.linter()
Error: opts.eslint option is required
    at new Linter (/Users/zeke/.trymodule/node_modules/standard-engine/index.js:32:27)
    at Object.Linter (/Users/zeke/.trymodule/node_modules/standard-engine/index.js:26:41)
   ...

Passing in eslint and an empty object works though:

~/forks/standard-engine master* 25s
❯ node        
> const eslint = require('.')
undefined
> const standard = require('.').linter({eslint:eslint, eslintConfig: {}})

I think a nicer behavior would be to allow the options to be undefined, defaulting to vanilla eslint if unspecified.

Errors when processing valid code

When I use standard such as this:

cat test.js | standard --fix --stdin 1> result.js

And test.js contains valid StandardJS code:

var foo = require('bar')

Then instead of emitting the file it returns an empty string and throws this error:

fs.js:2220
  fs.writeSync(this.fd, data, 0, data.length);
                                     ^
TypeError: Cannot read property 'length' of undefined
    at SyncWriteStream.write (fs.js:2220:38)
    at onResult (/usr/local/lib/node_modules/standard/node_modules/standard-engine/bin/cmd.js:101:22)
    at /usr/local/lib/node_modules/standard/node_modules/standard-engine/index.js:180:5
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Where is ignore from package read?

I seem to have stared myself blind at the code. I cannot seem to find where you read the values of package.json "lintername".ignore and use that to extend the list of default ignores. It seems that the only values read from package.json is parser and globals?

https://github.com/Flet/standard-engine/blob/master/index.js#L128-L137

I verified that it works with ignoring, so I'm obviously missing something. I'd appreciate it, if you would point me in the right direction :-)

An in-range update of eslint-config-standard-jsx is breaking the build 🚨

The devDependency eslint-config-standard-jsx was updated from 8.0.1 to 8.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-standard-jsx is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 3 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Remove eslint

From #43 (comment):

I think we should remove eslint from this package and make the user pass in whatever version they want. That makes more sense anyway, since the user is specifying the rules, and those will be dependent on the eslint version.

This is a breaking change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.