standard
Advanced tools
Comparing version
242
AUTHORS.md
@@ -5,74 +5,172 @@ # Authors | ||
- Feross Aboukhadijeh (feross@feross.org) | ||
- Jonny Buchanan (jonathan.buchanan@gmail.com) | ||
- Dan Flettre (fletd01@yahoo.com) | ||
- Brandon Horst (brandonhorst@gmail.com) | ||
- Yoshua Wuyts (yoshuawuyts@gmail.com) | ||
- Alexander Gugel (alexander.gugel@gmail.com) | ||
- Nate Goldman (nnmgoldman@gmail.com) | ||
- Max Ogden (max@maxogden.com) | ||
- Ricardo Barros (ricardofbarros@hotmail.com) | ||
- Yoshua Wuyts (i@yoshuawuyts.com) | ||
- Shahar Or (mightyiampresence@gmail.com) | ||
- Brent Burgoyne (bburgoyne@instructure.com) | ||
- Santiago Gil (gil.educaciontdf@gmail.com) | ||
- Vasiliy Loginevskiy (yeti-or@yandex-team.ru) | ||
- Joe Lencioni (joe.lencioni@brigade.com) | ||
- Leo Melin (leo.melin@eee.do) | ||
- G. Kay Lee (balancetraveller+github@gmail.com) | ||
- Lorenzo Villani (lorenzo@villani.me) | ||
- Ahmad Nassri (ahmad@ahmadnassri.com) | ||
- Mathias Buus (mathiasbuus@gmail.com) | ||
- Alex Potsides (alex@achingbrain.net) | ||
- Dan Lee (dlee@yammer-inc.com) | ||
- ishamf (ishamf@users.noreply.github.com) | ||
- Eric Zeng (leizeng@thoughtworks.com) | ||
- Cesar Andreu (cesarandreu@gmail.com) | ||
- Daniel Cousens (dcousens@users.noreply.github.com) | ||
- Enikő Nagy (eenagy@users.noreply.github.com) | ||
- Matthieu Prat (matthieuprat@gmail.com) | ||
- Dany Shaanan (danyshaanan@gmail.com) | ||
- Thomas Reggi (socialtr@gmail.com) | ||
- Stephen Kubovic (skubovic@gmail.com) | ||
- David Keijser (keijser@gmail.com) | ||
- Nick Colley (nickcolley7@gmail.com) | ||
- Florian Ebeling (mail@florianebeling.com) | ||
- Rico Sta. Cruz (rstacruz@users.noreply.github.com) | ||
- reggi (thomas@reggi.com) | ||
- Machisté N. Quintana (mnquintana@users.noreply.github.com) | ||
- Jiri Spac (capajj@gmail.com) | ||
- Sonny Piers (sonny@fastmail.net) | ||
- fscherwi (fscherwi@users.noreply.github.com) | ||
- Gustav Nikolaj Olsen (gno@one.com) | ||
- skorlir (skorlir@gmail.com) | ||
- JP Richardson (jprichardson@gmail.com) | ||
- chenxsan (chenxsan@users.noreply.github.com) | ||
- Tara Z. Manicsic (tara@modulus.io) | ||
- Jakub Elżbieciak (jelz@post.pl) | ||
- Dale Jefferson (dale@dalejefferson.com) | ||
- Paul Kernfeld (paulkernfeld@gmail.com) | ||
- rajcoss (nagrajan@ciena.com) | ||
- Joe Whitfield-Seed (joeseed86@gmail.com) | ||
- botbotbot (tkroputa@gmail.com) | ||
- Žiga Vidic (zigomir@gmail.com) | ||
- Wade Simmons (wsimmons@gmail.com) | ||
- Tushar Mathur (tusharmath@gmail.com) | ||
- Joshua Jabbour (code@joshuajabbour.com) | ||
- Zeke Sikelianos (zeke@sikelianos.com) | ||
- darren higgins (darrhiggs@users.noreply.github.com) | ||
- Joris Blaak (joris@label305.com) | ||
- CodinCat (a55951234@gmail.com) | ||
- Ruben Schmidmeister (ruben.schmidmeister@icloud.com) | ||
- Aleksey Bobyr (alexsey.bobyr@lifestreet.com) | ||
- David Moseley (davidmoseley@gmail.com) | ||
- Timon van Spronsen (timonvanspronsen@outlook.com) | ||
- Richard Littauer (richard.littauer@gmail.com) | ||
- Morton Fox (github@qslw.com) | ||
- Jason Kurian (JaKXz@users.noreply.github.com) | ||
- Pau Ramon Revilla (masylum@gmail.com) | ||
- Tim Oxley (secoif@gmail.com) | ||
- Linus Unnebäck (linus@folkdatorn.se) | ||
- sam (chenxsan@gmail.com) | ||
- Robin Whittleton (robin.whittleton@digital.cabinet-office.gov.uk) | ||
- Feross Aboukhadijeh ([feross@feross.org](mailto:feross@feross.org)) | ||
- Jonny Buchanan ([jonathan.buchanan@gmail.com](mailto:jonathan.buchanan@gmail.com)) | ||
- Dan Flettre ([flettre@gmail.com](mailto:flettre@gmail.com)) | ||
- Brandon Horst ([brandonhorst@gmail.com](mailto:brandonhorst@gmail.com)) | ||
- Yoshua Wuyts ([yoshuawuyts@gmail.com](mailto:yoshuawuyts@gmail.com)) | ||
- Alexander Gugel ([alexander.gugel@gmail.com](mailto:alexander.gugel@gmail.com)) | ||
- Nate Goldman ([nnmgoldman@gmail.com](mailto:nnmgoldman@gmail.com)) | ||
- Max Ogden ([max@maxogden.com](mailto:max@maxogden.com)) | ||
- Ricardo Barros ([ricardofbarros@hotmail.com](mailto:ricardofbarros@hotmail.com)) | ||
- Yoshua Wuyts ([i@yoshuawuyts.com](mailto:i@yoshuawuyts.com)) | ||
- Shahar Or ([mightyiampresence@gmail.com](mailto:mightyiampresence@gmail.com)) | ||
- Brent Burgoyne ([bburgoyne@instructure.com](mailto:bburgoyne@instructure.com)) | ||
- Santiago Gil ([gil.educaciontdf@gmail.com](mailto:gil.educaciontdf@gmail.com)) | ||
- Vasiliy Loginevskiy ([yeti-or@yandex-team.ru](mailto:yeti-or@yandex-team.ru)) | ||
- Joe Lencioni ([joe.lencioni@brigade.com](mailto:joe.lencioni@brigade.com)) | ||
- Leo Melin ([leo.melin@eee.do](mailto:leo.melin@eee.do)) | ||
- G. Kay Lee ([balancetraveller+github@gmail.com](mailto:balancetraveller+github@gmail.com)) | ||
- Lorenzo Villani ([lorenzo@villani.me](mailto:lorenzo@villani.me)) | ||
- Ahmad Nassri ([ahmad@ahmadnassri.com](mailto:ahmad@ahmadnassri.com)) | ||
- Mathias Buus ([mathiasbuus@gmail.com](mailto:mathiasbuus@gmail.com)) | ||
- Alex Potsides ([alex@achingbrain.net](mailto:alex@achingbrain.net)) | ||
- Dan Lee ([dlee@yammer-inc.com](mailto:dlee@yammer-inc.com)) | ||
- ishamf ([ishamf@users.noreply.github.com](mailto:ishamf@users.noreply.github.com)) | ||
- Eric Zeng ([leizeng@thoughtworks.com](mailto:leizeng@thoughtworks.com)) | ||
- Cesar Andreu ([cesarandreu@gmail.com](mailto:cesarandreu@gmail.com)) | ||
- Daniel Cousens ([dcousens@users.noreply.github.com](mailto:dcousens@users.noreply.github.com)) | ||
- Enikő Nagy ([eenagy@users.noreply.github.com](mailto:eenagy@users.noreply.github.com)) | ||
- Matthieu Prat ([matthieuprat@gmail.com](mailto:matthieuprat@gmail.com)) | ||
- Dany Shaanan ([danyshaanan@gmail.com](mailto:danyshaanan@gmail.com)) | ||
- Thomas Reggi ([socialtr@gmail.com](mailto:socialtr@gmail.com)) | ||
- Stephen Kubovic ([skubovic@gmail.com](mailto:skubovic@gmail.com)) | ||
- David Keijser ([keijser@gmail.com](mailto:keijser@gmail.com)) | ||
- Nick Colley ([nickcolley7@gmail.com](mailto:nickcolley7@gmail.com)) | ||
- Florian Ebeling ([mail@florianebeling.com](mailto:mail@florianebeling.com)) | ||
- Rico Sta. Cruz ([rstacruz@users.noreply.github.com](mailto:rstacruz@users.noreply.github.com)) | ||
- reggi ([thomas@reggi.com](mailto:thomas@reggi.com)) | ||
- Machisté N. Quintana ([mnquintana@users.noreply.github.com](mailto:mnquintana@users.noreply.github.com)) | ||
- Jiri Spac ([capajj@gmail.com](mailto:capajj@gmail.com)) | ||
- Sonny Piers ([sonny@fastmail.net](mailto:sonny@fastmail.net)) | ||
- fscherwi ([fscherwi@users.noreply.github.com](mailto:fscherwi@users.noreply.github.com)) | ||
- Gustav Nikolaj Olsen ([gno@one.com](mailto:gno@one.com)) | ||
- skorlir ([skorlir@gmail.com](mailto:skorlir@gmail.com)) | ||
- JP Richardson ([jprichardson@gmail.com](mailto:jprichardson@gmail.com)) | ||
- chenxsan ([chenxsan@users.noreply.github.com](mailto:chenxsan@users.noreply.github.com)) | ||
- Tara Z. Manicsic ([tara@modulus.io](mailto:tara@modulus.io)) | ||
- Jakub Elżbieciak ([jelz@post.pl](mailto:jelz@post.pl)) | ||
- Dale Jefferson ([dale@dalejefferson.com](mailto:dale@dalejefferson.com)) | ||
- Paul Kernfeld ([paulkernfeld@gmail.com](mailto:paulkernfeld@gmail.com)) | ||
- rajcoss ([nagrajan@ciena.com](mailto:nagrajan@ciena.com)) | ||
- Joe Whitfield-Seed ([joeseed86@gmail.com](mailto:joeseed86@gmail.com)) | ||
- botbotbot ([tkroputa@gmail.com](mailto:tkroputa@gmail.com)) | ||
- Žiga Vidic ([zigomir@gmail.com](mailto:zigomir@gmail.com)) | ||
- Wade Simmons ([wsimmons@gmail.com](mailto:wsimmons@gmail.com)) | ||
- Tushar Mathur ([tusharmath@gmail.com](mailto:tusharmath@gmail.com)) | ||
- Joshua Jabbour ([code@joshuajabbour.com](mailto:code@joshuajabbour.com)) | ||
- Zeke Sikelianos ([zeke@sikelianos.com](mailto:zeke@sikelianos.com)) | ||
- darren higgins ([darrhiggs@users.noreply.github.com](mailto:darrhiggs@users.noreply.github.com)) | ||
- Joris Blaak ([joris@label305.com](mailto:joris@label305.com)) | ||
- CodinCat ([a55951234@gmail.com](mailto:a55951234@gmail.com)) | ||
- Ruben Schmidmeister ([ruben.schmidmeister@icloud.com](mailto:ruben.schmidmeister@icloud.com)) | ||
- Aleksey Bobyr ([alexsey.bobyr@lifestreet.com](mailto:alexsey.bobyr@lifestreet.com)) | ||
- David Moseley ([davidmoseley@gmail.com](mailto:davidmoseley@gmail.com)) | ||
- Timon van Spronsen ([timonvanspronsen@outlook.com](mailto:timonvanspronsen@outlook.com)) | ||
- Richard Littauer ([richard.littauer@gmail.com](mailto:richard.littauer@gmail.com)) | ||
- Morton Fox ([github@qslw.com](mailto:github@qslw.com)) | ||
- Jason Kurian ([JaKXz@users.noreply.github.com](mailto:JaKXz@users.noreply.github.com)) | ||
- Pau Ramon Revilla ([masylum@gmail.com](mailto:masylum@gmail.com)) | ||
- Tim Oxley ([secoif@gmail.com](mailto:secoif@gmail.com)) | ||
- Linus Unnebäck ([linus@folkdatorn.se](mailto:linus@folkdatorn.se)) | ||
- sam ([chenxsan@gmail.com](mailto:chenxsan@gmail.com)) | ||
- Robin Whittleton ([robin.whittleton@digital.cabinet-office.gov.uk](mailto:robin.whittleton@digital.cabinet-office.gov.uk)) | ||
- Alex Moreno ([alexmorenodealmeida@gmail.com](mailto:alexmorenodealmeida@gmail.com)) | ||
- Ekaterina Prigara ([ekaterina@prigara.com](mailto:ekaterina@prigara.com)) | ||
- Erik Müller ([e.mueller@epages.com](mailto:e.mueller@epages.com)) | ||
- Lukas Oppermann ([oppermann.lukas@googlemail.com](mailto:oppermann.lukas@googlemail.com)) | ||
- Joshua P. Colvin ([colvinj@ewashtenaw.org](mailto:colvinj@ewashtenaw.org)) | ||
- David Lavieri ([daviddlavier@gmail.com](mailto:daviddlavier@gmail.com)) | ||
- Yanxi ([blogbbs@gmail.com](mailto:blogbbs@gmail.com)) | ||
- Michael Cavalea ([callmecavs@gmail.com](mailto:callmecavs@gmail.com)) | ||
- Joshua Colvin ([joshua@joshuacolvin.net](mailto:joshua@joshuacolvin.net)) | ||
- despia ([despia@users.noreply.github.com](mailto:despia@users.noreply.github.com)) | ||
- Peter Jenkins ([peterjenkins@users.noreply.github.com](mailto:peterjenkins@users.noreply.github.com)) | ||
- nyuszika7h ([nyuszika7h@openmailbox.org](mailto:nyuszika7h@openmailbox.org)) | ||
- Asoul Yang ([azx754@gmail.com](mailto:azx754@gmail.com)) | ||
- Peter Dave Hello ([hsu@peterdavehello.org](mailto:hsu@peterdavehello.org)) | ||
- Wayou Liu ([liuwayong@gmail.com](mailto:liuwayong@gmail.com)) | ||
- Thomas Watson ([w@tson.dk](mailto:w@tson.dk)) | ||
- Pablo Varela ([pablopunk@users.noreply.github.com](mailto:pablopunk@users.noreply.github.com)) | ||
- xiaoyu2er ([zongyanqi@foxmail.com](mailto:zongyanqi@foxmail.com)) | ||
- devjin0617 ([devjin0617@gmail.com](mailto:devjin0617@gmail.com)) | ||
- ehmicky ([ehmicky@users.noreply.github.com](mailto:ehmicky@users.noreply.github.com)) | ||
- Stanislav Termosa ([termosa.stanislav@gmail.com](mailto:termosa.stanislav@gmail.com)) | ||
- yanxiaodi ([929213769@qq.com](mailto:929213769@qq.com)) | ||
- developerjin ([devjin0617@gmail.com](mailto:devjin0617@gmail.com)) | ||
- Mark Peace ([mark.peace@neotechnology.com](mailto:mark.peace@neotechnology.com)) | ||
- Alexandre Nicastro ([kryndex@gmail.com](mailto:kryndex@gmail.com)) | ||
- Ivan Ying ([yyjazsf@live.cn](mailto:yyjazsf@live.cn)) | ||
- 薛定谔的猫 ([hh_2013@foxmail.com](mailto:hh_2013@foxmail.com)) | ||
- Robin ([almigod0718@gmail.com](mailto:almigod0718@gmail.com)) | ||
- CafeLungo ([CafeLungo@users.noreply.github.com](mailto:CafeLungo@users.noreply.github.com)) | ||
- Antério Vieira ([anteriovieira@gmail.com](mailto:anteriovieira@gmail.com)) | ||
- Bret Comnes ([bcomnes@gmail.com](mailto:bcomnes@gmail.com)) | ||
- Jared Reich ([jaredreich@gmail.com](mailto:jaredreich@gmail.com)) | ||
- Igor Santos ([igorsantos07@gmail.com](mailto:igorsantos07@gmail.com)) | ||
- daper ([david@daper.email](mailto:david@daper.email)) | ||
- Sola ([airsolakey@icloud.com](mailto:airsolakey@icloud.com)) | ||
- Lion Yang ([lion@aosc.xyz](mailto:lion@aosc.xyz)) | ||
- Joseph Frazier ([1212jtraceur@gmail.com](mailto:1212jtraceur@gmail.com)) | ||
- Emanuele ([my.burning@gmail.com](mailto:my.burning@gmail.com)) | ||
- Jakob Krigovsky ([jakob@krigovsky.com](mailto:jakob@krigovsky.com)) | ||
- Joe Boyle ([joe.boyle@jibo.com](mailto:joe.boyle@jibo.com)) | ||
- Adrian Trunzo ([adrian@instoredoes.com](mailto:adrian@instoredoes.com)) | ||
- Pablo Varela ([pablovarela182@gmail.com](mailto:pablovarela182@gmail.com)) | ||
- Luan Vicente ([hi@idlua.me](mailto:hi@idlua.me)) | ||
- Tony Finn ([tony@tonyfinn.com](mailto:tony@tonyfinn.com)) | ||
- tumobi ([tumobi@163.com](mailto:tumobi@163.com)) | ||
- Maarten Ackermans ([maarten.ackermans@gmail.com](mailto:maarten.ackermans@gmail.com)) | ||
- ★★ (งツ)ว ★★ ([theaichholzer@gmail.com](mailto:theaichholzer@gmail.com)) | ||
- Fahad Hossain ([fa7ad@users.noreply.github.com](mailto:fa7ad@users.noreply.github.com)) | ||
- kaijun ([cadenho@hotmail.com](mailto:cadenho@hotmail.com)) | ||
- Andre Sattler ([andresattler.webdev@gmail.com](mailto:andresattler.webdev@gmail.com)) | ||
- Lucas Baldassari ([lucasbaldassari@gmail.com](mailto:lucasbaldassari@gmail.com)) | ||
- WangJie ([i@i8e.net](mailto:i@i8e.net)) | ||
- Theophilus Omoregbee ([theo4u@ymail.com](mailto:theo4u@ymail.com)) | ||
- Charlie Gerard ([charlie.a.gerard@gmail.com](mailto:charlie.a.gerard@gmail.com)) | ||
- Christopher J. Brody ([chris.brody@gmail.com](mailto:chris.brody@gmail.com)) | ||
- George Cheng ([Gerhut@GMail.com](mailto:Gerhut@GMail.com)) | ||
- dangen ([23185799+dangen-effy@users.noreply.github.com](mailto:23185799+dangen-effy@users.noreply.github.com)) | ||
- Munieru ([20086673+munierujp@users.noreply.github.com](mailto:20086673+munierujp@users.noreply.github.com)) | ||
- Justin ([jus.russell@gmail.com](mailto:jus.russell@gmail.com)) | ||
- Austin Orth ([aorth@niche.com](mailto:aorth@niche.com)) | ||
- Chris Brody ([chris.brody@gmail.com](mailto:chris.brody@gmail.com)) | ||
- kohashi ([hako584@gmail.com](mailto:hako584@gmail.com)) | ||
- tomastrg ([tomastrg22@gmail.com](mailto:tomastrg22@gmail.com)) | ||
- aaronhong ([aa.hong@gmail.com](mailto:aa.hong@gmail.com)) | ||
- Amabel ([luoweibinb@gmail.com](mailto:luoweibinb@gmail.com)) | ||
- Elad Chen ([eladchen@gmail.com](mailto:eladchen@gmail.com)) | ||
- Dave Carlson ([davecarlson@users.noreply.github.com](mailto:davecarlson@users.noreply.github.com)) | ||
- epixian ([38962121+epixian@users.noreply.github.com](mailto:38962121+epixian@users.noreply.github.com)) | ||
- Yuriy Dybskiy ([yuriy@dybskiy.com](mailto:yuriy@dybskiy.com)) | ||
- MarvinJWendt ([github@marvinjwendt.com](mailto:github@marvinjwendt.com)) | ||
- LitoMore ([litomore@gmail.com](mailto:litomore@gmail.com)) | ||
- Feross ([feross@feross.org](mailto:feross@feross.org)) | ||
- Vincent Weevers ([mail@vincentweevers.nl](mailto:mail@vincentweevers.nl)) | ||
- Shahar Or (mightyiam) ([mightyiampresence@gmail.com](mailto:mightyiampresence@gmail.com)) | ||
- にしくま ([graphic.extra005@gmail.com](mailto:graphic.extra005@gmail.com)) | ||
- Eric Berry ([coderberry@gmail.com](mailto:coderberry@gmail.com)) | ||
- Abdullah Alansari ([ahimta@gmail.com](mailto:ahimta@gmail.com)) | ||
- Adam Jones ([jones_adam@rocketmail.com](mailto:jones_adam@rocketmail.com)) | ||
- zhangyu ([zhangyu29@asiainfo.com](mailto:zhangyu29@asiainfo.com)) | ||
- Shahar Dawn Or ([mightyiampresence@gmail.com](mailto:mightyiampresence@gmail.com)) | ||
- Joshua Goran ([35858093+joshuagoran@users.noreply.github.com](mailto:35858093+joshuagoran@users.noreply.github.com)) | ||
- HCLonely ([h1606051253@gmail.com](mailto:h1606051253@gmail.com)) | ||
- Italo ([italoaurelior@gmail.com](mailto:italoaurelior@gmail.com)) | ||
- Vrq ([januszveiro@gmail.com](mailto:januszveiro@gmail.com)) | ||
- 王刚 ([wg0121@outlook.com](mailto:wg0121@outlook.com)) | ||
- Javier Mendoza ([37485620+javiermendozain@users.noreply.github.com](mailto:37485620+javiermendozain@users.noreply.github.com)) | ||
- Ciffelia ([mc.prince.0203@gmail.com](mailto:mc.prince.0203@gmail.com)) | ||
- Nacho Caiafa ([nachokai@outlook.com](mailto:nachokai@outlook.com)) | ||
- Tom Clark ([tom@octue.com](mailto:tom@octue.com)) | ||
- Septiana Yoga ([septianayoga30@gmail.com](mailto:septianayoga30@gmail.com)) | ||
- logustra ([logustra@outlook.com](mailto:logustra@outlook.com)) | ||
- Kid ([44045911+kidonng@users.noreply.github.com](mailto:44045911+kidonng@users.noreply.github.com)) | ||
- Aki ([71239005+AkiaCode@users.noreply.github.com](mailto:71239005+AkiaCode@users.noreply.github.com)) | ||
- HonkingGoose ([34918129+HonkingGoose@users.noreply.github.com](mailto:34918129+HonkingGoose@users.noreply.github.com)) | ||
- Alex Grover ([hello@alexgrover.me](mailto:hello@alexgrover.me)) | ||
- Todd Bluhm ([toddbluhm@gmail.com](mailto:toddbluhm@gmail.com)) | ||
- alanclarke ([alan@qubit.com](mailto:alan@qubit.com)) | ||
- Csaba Maulis ([csaba@om4.com.au](mailto:csaba@om4.com.au)) | ||
#### Generated by bin/update-authors.sh. | ||
#### Generated by tools/update-authors.sh. |
#!/usr/bin/env node | ||
/* eslint-disable no-var */ | ||
if (process.version.match(/v(\d+)\./)[1] < 4) { | ||
console.error('standard: Node v4 or greater is required. `standard` did not run.') | ||
var match = process.version.match(/v(\d+)\.(\d+)/) | ||
var major = parseInt(match[1], 10) | ||
var minor = parseInt(match[2], 10) | ||
if (major >= 11 || (major === 10 && minor >= 12)) { | ||
require('standard-engine').cli(require('../options')) | ||
} else { | ||
var opts = require('../options') | ||
require('standard-engine').cli(opts) | ||
console.error('standard: Node 10.12.0 or greater is required. `standard` did not run.') | ||
} | ||
@@ -1,4 +0,5 @@ | ||
var Linter = require('standard-engine').linter | ||
var opts = require('./options') | ||
/*! standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
const Linter = require('standard-engine').linter | ||
const opts = require('./options') | ||
module.exports = new Linter(opts) |
@@ -1,4 +0,4 @@ | ||
var eslint = require('eslint') | ||
var path = require('path') | ||
var pkg = require('./package.json') | ||
const eslint = require('eslint') | ||
const path = require('path') | ||
const pkg = require('./package.json') | ||
@@ -8,3 +8,3 @@ module.exports = { | ||
cmd: 'standard', | ||
eslint: eslint, | ||
eslint, | ||
eslintConfig: { | ||
@@ -11,0 +11,0 @@ configFile: path.join(__dirname, 'eslintrc.json') |
{ | ||
"name": "standard", | ||
"description": "JavaScript Standard Style", | ||
"version": "8.6.0", | ||
"version": "16.0.4", | ||
"author": { | ||
"name": "Feross Aboukhadijeh", | ||
"email": "feross@feross.org", | ||
"name": "Feross Aboukhadijeh", | ||
"url": "http://feross.org/" | ||
"url": "https://feross.org" | ||
}, | ||
"bin": "./bin/cmd.js", | ||
"bin": { | ||
"standard": "bin/cmd.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/feross/standard/issues" | ||
"url": "https://github.com/standard/standard/issues" | ||
}, | ||
"dependencies": { | ||
"eslint": "~3.10.2", | ||
"eslint-config-standard": "6.2.1", | ||
"eslint-config-standard-jsx": "3.2.0", | ||
"eslint-plugin-promise": "~3.4.0", | ||
"eslint-plugin-react": "~6.7.1", | ||
"eslint-plugin-standard": "~2.0.1", | ||
"standard-engine": "~5.2.0" | ||
"eslint": "~7.18.0", | ||
"eslint-config-standard": "16.0.3", | ||
"eslint-config-standard-jsx": "10.0.0", | ||
"eslint-plugin-import": "~2.24.2", | ||
"eslint-plugin-node": "~11.1.0", | ||
"eslint-plugin-promise": "~5.1.0", | ||
"eslint-plugin-react": "~7.25.1", | ||
"standard-engine": "^14.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^7.0.0", | ||
"cross-spawn": "^5.0.1", | ||
"minimist": "^1.2.0", | ||
"mkdirp": "^0.5.1", | ||
"run-parallel-limit": "^1.0.3", | ||
"standard-packages": "^3.1.9", | ||
"tape": "^4.6.0" | ||
"cross-spawn": "^7.0.3", | ||
"hallmark": "^3.1.0", | ||
"minimist": "^1.2.5", | ||
"run-parallel-limit": "^1.1.0", | ||
"run-series": "^1.1.9", | ||
"simple-get": "^4.0.0", | ||
"tape": "^5.3.1" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=10.12.0" | ||
}, | ||
"homepage": "http://standardjs.com", | ||
"homepage": "https://standardjs.com", | ||
"keywords": [ | ||
@@ -65,12 +68,24 @@ "JavaScript Standard Style", | ||
"type": "git", | ||
"url": "git://github.com/feross/standard.git" | ||
"url": "git://github.com/standard/standard.git" | ||
}, | ||
"scripts": { | ||
"test": "./bin/cmd.js --verbose && tape test/*.js", | ||
"test-disabled": "npm test -- --disabled", | ||
"test-offline": "npm test -- --offline", | ||
"test-offline-quick": "npm test -- --offline --quick", | ||
"test-quick": "npm test -- --quick", | ||
"update-authors": "./bin/update-authors.sh" | ||
} | ||
"test": "npm run test-internal && npm run test-external", | ||
"test-internal": "./bin/cmd.js --verbose && tape test/*.js", | ||
"test-external": "tape test/external/*.js", | ||
"update-authors": "./tools/update-authors.sh && hallmark --fix AUTHORS.md" | ||
}, | ||
"funding": [ | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/feross" | ||
}, | ||
{ | ||
"type": "patreon", | ||
"url": "https://www.patreon.com/feross" | ||
}, | ||
{ | ||
"type": "consulting", | ||
"url": "https://feross.org/support" | ||
} | ||
] | ||
} |
762
README.md
<h1 align="center"> | ||
<a href="http://standardjs.com"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard - JavaScript Style Guide" width="200"></a> | ||
<a href="https://standardjs.com"><img src="https://cdn.rawgit.com/standard/standard/master/sticker.svg" alt="Standard - JavaScript Style Guide" width="200"></a> | ||
<br> | ||
@@ -9,66 +9,53 @@ JavaScript Standard Style | ||
<h4 align="center">One JavaScript Style Guide to Rule Them All</h4> | ||
<p align="center"> | ||
<a href="https://travis-ci.org/feross/standard"><img src="https://img.shields.io/travis/feross/standard/master.svg" alt="Travis"></a> | ||
<a href="https://www.npmjs.com/package/standard"><img src="https://img.shields.io/npm/dm/standard.svg" alt="npm downloads"></a> | ||
<a href="https://discord.gg/ZegqCBr"><img src="https://img.shields.io/discord/612704110008991783" alt="discord"></a> | ||
<a href="https://github.com/standard/standard/actions/workflows/test-external.yml"><img src="https://github.com/standard/standard/actions/workflows/test-external.yml/badge.svg?branch=master" alt="External tests"></a> | ||
<a href="https://github.com/standard/standard/actions/workflows/test-internal.yml"><img src="https://github.com/standard/standard/actions/workflows/test-internal.yml/badge.svg?branch=master" alt="Internal tests"></a> | ||
<a href="https://github.com/standard/standard/actions?query=workflow%3A%22Old+test%22"><img src="https://github.com/standard/standard/workflows/Old%20test/badge.svg" alt="status badge old Node test"></a> | ||
<a href="https://www.npmjs.com/package/standard"><img src="https://img.shields.io/npm/v/standard.svg" alt="npm version"></a> | ||
<a href="https://www.npmjs.com/package/eslint-config-standard"><img src="https://img.shields.io/npm/dm/eslint-config-standard.svg" alt="npm downloads"></a> | ||
<a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard - JavaScript Style Guide"></a> | ||
</p> | ||
<br> | ||
No decisions to make. No `.eslintrc`, `.jshintrc`, or `.jscsrc` files to manage. It just | ||
works. | ||
<h5 align="center"> | ||
Sponsored by <a href="https://wormhole.app/?utm_medium=sponsorship&utm_source=standard&utm_campaign=feross"><img src="https://cdn.rawgit.com/standard/standard/master/docs/logos/wormhole.png" alt="Wormhole" height=50 valign="middle"></a> | ||
</h5> | ||
This module saves you (and others!) time in two ways: | ||
<p align="center"> | ||
<a href="/docs/README-en.md">English</a> • | ||
<a href="/docs/README-esla.md">Español (Latinoamérica)</a> • | ||
<a href="/docs/README-fr.md">Français</a> • | ||
<a href="/docs/README-id.md">Bahasa Indonesia</a> • | ||
<a href="/docs/README-iteu.md">Italiano (Italian)</a> • | ||
<a href="/docs/README-ja.md">日本語 (Japanese)</a> • | ||
<a href="/docs/README-kokr.md">한국어 (Korean)</a> • | ||
<a href="/docs/README-ptbr.md">Português (Brasil)</a> • | ||
<a href="/docs/README-zhcn.md">简体中文 (Simplified Chinese)</a> • | ||
<a href="/docs/README-zhtw.md">繁體中文 (Taiwanese Mandarin)</a> | ||
</p> | ||
- **No configuration.** The easiest way to enforce consistent style in your | ||
project. Just drop it in. | ||
- **Catch style errors before they're submitted in PRs.** Saves precious code | ||
review time by eliminating back-and-forth between maintainer and contributor. | ||
## JavaScript style guide, linter, and formatter | ||
Install with: | ||
This module saves you (and others!) time in three ways: | ||
``` | ||
npm install standard | ||
``` | ||
- **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. | ||
### The Rules | ||
Give it a try by running `npx standard --fix` right now! | ||
- **2 spaces** – for indentation | ||
- **Single quotes for strings** – except to avoid escaping | ||
- **No unused variables** – this one catches *tons* of bugs! | ||
- **No semicolons** – [It's][1] [fine.][2] [Really!][3] | ||
- **Never start a line with `(`, `[`, or `` ` ``** | ||
- This is the **only** gotcha with omitting semicolons – *automatically checked for you!* | ||
- [More details][4] | ||
- **Space after keywords** `if (condition) { ... }` | ||
- **Space after function name** `function name (arg) { ... }` | ||
- Always use `===` instead of `==` – but `obj == null` is allowed to check `null || undefined`. | ||
- Always handle the node.js `err` function parameter | ||
- Always prefix browser globals with `window` – except `document` and `navigator` are okay | ||
- Prevents accidental use of poorly-named browser globals like `open`, `length`, | ||
`event`, and `name`. | ||
- **And [more goodness][5]** – *give `standard` a try today!* | ||
[1]: http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding | ||
[2]: http://inimino.org/~inimino/blog/javascript_semicolons | ||
[3]: https://www.youtube.com/watch?v=gsfbh17Ax9I | ||
[4]: RULES.md#semicolons | ||
[5]: RULES.md#javascript-standard-style | ||
To get a better idea, take a look at | ||
[a sample file](https://github.com/feross/bittorrent-dht/blob/master/client.js) written | ||
in JavaScript Standard Style, or check out some of | ||
[the repositories](https://github.com/feross/standard-packages/blob/master/all.json) that use | ||
`standard`. | ||
## Table of Contents | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- Quick start | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [What you might do if you're clever](#what-you-might-do-if-youre-clever) | ||
- [Badge](#badge) | ||
- [Text editor plugins](#text-editor-plugins) | ||
- [FAQ](#faq) | ||
- [Why would I use JavaScript Standard Style?](#why-would-i-use-javascript-standard-style) | ||
- FAQ | ||
- [Why should I use JavaScript Standard Style?](#why-should-i-use-javascript-standard-style) | ||
- [Who uses JavaScript Standard Style?](#who-uses-javascript-standard-style) | ||
- [Are there text editor plugins?](#are-there-text-editor-plugins) | ||
- [Is there a readme badge?](#is-there-a-readme-badge) | ||
- [I disagree with rule X, can you change it?](#i-disagree-with-rule-x-can-you-change-it) | ||
@@ -78,36 +65,31 @@ - [But this isn't a real web standard!](#but-this-isnt-a-real-web-standard) | ||
- [How do I ignore files?](#how-do-i-ignore-files) | ||
- [How do I hide a certain warning?](#how-do-i-hide-a-certain-warning) | ||
- [How do I disable a rule?](#how-do-i-disable-a-rule) | ||
- [I use a library that pollutes the global namespace. How do I prevent "variable is not defined" errors?](#i-use-a-library-that-pollutes-the-global-namespace-how-do-i-prevent-variable-is-not-defined-errors) | ||
- [Can I use a custom JS parser for bleeding-edge ES next support?](#can-i-use-a-custom-js-parser-for-bleeding-edge-es-next-support) | ||
- [Can I use a JavaScript language variant, like Flow?](#can-i-use-a-javascript-language-variant-like-flow) | ||
- [Can you make rule X configurable?](#can-you-make-rule-x-configurable) | ||
- [What about Web Workers?](#what-about-web-workers) | ||
- [What about Mocha, Jasmine, QUnit, etc?](#what-about-mocha-jasmine-qunit-etc) | ||
- [How do I use experimental JavaScript (ES Next) features?](#how-do-i-use-experimental-javascript-es-next-features) | ||
- [Can I use a JavaScript language variant, like Flow or TypeScript?](#can-i-use-a-javascript-language-variant-like-flow-or-typescript) | ||
- [What about Mocha, Jest, Jasmine, QUnit, etc?](#what-about-mocha-jest-jasmine-qunit-etc) | ||
- [What about Web Workers and Service Workers?](#what-about-web-workers-and-service-workers) | ||
- [What is the difference between warnings and errors?](#what-is-the-difference-between-warnings-and-errors) | ||
- [Can I check code inside of Markdown or HTML files?](#can-i-check-code-inside-of-markdown-or-html-files) | ||
- [Is there a Git `pre-commit` hook?](#is-there-a-git-pre-commit-hook) | ||
- [How do I make the output all colorful and *pretty*?](#how-do-i-make-the-output-all-colorful-and-pretty) | ||
- [I want to contribute to `standard`. What packages should I know about?](#i-want-to-contribute-to-standard-what-packages-should-i-know-about) | ||
- [Node.js API](#nodejs-api) | ||
- [`standard.lintText(text, [opts], callback)`](#standardlinttexttext-opts-callback) | ||
- [`standard.lintFiles(files, [opts], callback)`](#standardlintfilesfiles-opts-callback) | ||
- [IRC channel](#irc-channel) | ||
- [License](#license) | ||
- [How do I make the output all colorful and pretty?](#how-do-i-make-the-output-all-colorful-and-pretty) | ||
- [Is there a Node.js API?](#is-there-a-nodejs-api) | ||
- [How do I contribute to StandardJS?](#how-do-i-contribute-to-standardjs) | ||
## Install | ||
The easiest way to use JavaScript Standard Style to check your code is to install | ||
it globally as a Node command line program. To do so, simply run the following | ||
command in your terminal (flag `-g` installs `standard` globally on your system, | ||
omit it if you want to install in the current working directory): | ||
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: | ||
```bash | ||
npm install standard --global | ||
$ npm install standard --global | ||
``` | ||
Or, you can run this command to install `standard` locally, for use in your module: | ||
Or, you can install `standard` locally, for use in a single project: | ||
```bash | ||
npm install standard --save-dev | ||
$ npm install standard --save-dev | ||
``` | ||
[Node.js](http://nodejs.org) and [npm](https://npmjs.com) are required to run the preceding commands. | ||
*Note: To run the preceding commands, [Node.js](http://nodejs.org) and [npm](https://npmjs.com) must be installed.* | ||
@@ -126,5 +108,11 @@ ## Usage | ||
If you've installed `standard` locally, run with `npx` instead: | ||
```bash | ||
$ 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: | ||
sure to quote paths containing glob patterns so that they are expanded by | ||
`standard` instead of your shell: | ||
@@ -138,52 +126,110 @@ ```bash | ||
### What you might do if you're clever | ||
## What you might do if you're clever | ||
1. Add it to `package.json` | ||
```json | ||
{ | ||
"name": "my-cool-package", | ||
"devDependencies": { | ||
"standard": "*" | ||
}, | ||
"scripts": { | ||
"test": "standard && node my-tests.js" | ||
} | ||
} | ||
``` | ||
```json | ||
{ | ||
"name": "my-cool-package", | ||
"devDependencies": { | ||
"standard": "*" | ||
}, | ||
"scripts": { | ||
"test": "standard && node my-tests.js" | ||
} | ||
} | ||
``` | ||
2. Check style automatically when you run `npm test` | ||
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 '=='. | ||
``` | ||
```bash | ||
$ 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! | ||
### Badge | ||
This module saves you (and others!) time in three ways: | ||
Use this in one of your projects? Include one of these badges in your readme to | ||
let people know that your code is using the standard style. | ||
- **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. | ||
[](https://github.com/feross/standard) | ||
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. | ||
```markdown | ||
[](https://github.com/feross/standard) | ||
``` | ||
For more info, see the conference talk ["Write Perfect Code with Standard and | ||
ESLint"](https://www.youtube.com/watch?v=kuHfMw8j4xk). In this talk, you'll learn | ||
about linting, when to use `standard` versus `eslint`, and how `prettier` compares | ||
to `standard`. | ||
[](http://standardjs.com/) | ||
## Who uses JavaScript Standard Style? | ||
```markdown | ||
[](http://standardjs.com/) | ||
``` | ||
[<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/nodejs.png>](https://nodejs.org) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/npm.png>](https://www.npmjs.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/github.png>](https://github.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/wormhole.png>](https://wormhole.app) | | ||
|---|---|---|---| | ||
### Text editor plugins | ||
[<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/express.png>](http://expressjs.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/electron.png>](http://electron.atom.io) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/nuxtjs.png>](https://nuxtjs.org/) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/elastic.png>](https://www.elastic.co) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/mongodb.jpg>](https://www.mongodb.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/zendesk.png>](https://www.zendesk.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/brave.png>](https://www.brave.com) | [<img width=190 src=https://assets.vercel.com/image/upload/v1621541666/front/assets/logotype-black-on-white.png>](https://vercel.com) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/nodesource.png>](https://nodesource.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/nearform.png>](http://www.nearform.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/typeform.png>](https://www.typeform.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/gov-uk.png>](https://gds.blog.gov.uk) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/heroku.png>](https://www.heroku.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/saucelabs.png>](https://saucelabs.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/automattic.png>](https://automattic.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/godaddy.png>](https://www.godaddy.com) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/webtorrent.png>](https://webtorrent.io) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/ipfs.png>](https://ipfs.io) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/dat.png>](https://datproject.org) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/bitcoinjs.png>](https://bitcoinjs.org) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/voltra.png>](https://voltra.co) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/treasuredata.png>](https://www.treasuredata.com) | [<img alt="Free MIDIs, MIDI file downloads" width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/bitmidi.png>](https://bitmidi.com) | [<img width=190 alt="College essays, AP notes" src=https://cdn.rawgit.com/standard/standard/master/docs/logos/studynotes.jpg>](https://www.apstudynotes.org) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/optiopay.png>](https://www.optiopay.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/jaguar-landrover.png>](https://www.jlrtechincubator.com/jlrti/) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/bustle.jpg>](https://www.bustle.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/zentrick.png>](https://www.zentrick.com) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/greenkeeper.png>](https://greenkeeper.io) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/karma.png>](https://karma-runner.github.io) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/taser.png>](https://www.taser.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/neo4j.png>](https://www.neo4j.com) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/rentograph.png>](https://rentograph.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/eaze.png>](https://www.eaze.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/ctrl-alt-deseat.png>](https://www.ctrlaltdeseat.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/clevertech.png>](https://clevertech.biz) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/aragon.png>](https://aragon.org) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/flowsent.png>](https://www.flowsent.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/puma-browser.png>](https://www.pumabrowser.com/) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/webstorm.png>](https://www.jetbrains.com/webstorm/) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/fastify.png>](https://www.fastify.io) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/scuttlebutt.png>](https://www.scuttlebutt.nz) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/solid.png>](https://solid.inrupt.com) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/grab.png>](https://www.grab.com) | | ||
|---|---|---|---| | ||
| [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/jublia.png>](https://jublia.com/) | [<img width=190 src=https://cdn.rawgit.com/standard/standard/master/docs/logos/atom.png>](https://atom.io) | Your logo here | Your logo here | | ||
|---|---|---|---| | ||
In addition to companies, many community members use `standard` on packages that | ||
are [too numerous](https://raw.githubusercontent.com/standard/standard-packages/master/all.json) | ||
to list here. | ||
`standard` is also the top-starred linter in GitHub's | ||
[Clean Code Linter](https://github.com/showcases/clean-code-linters) showcase. | ||
## Are there text editor plugins? | ||
First, install `standard`. Then, install the appropriate plugin for your editor: | ||
#### [Sublime Text](https://www.sublimetext.com/) | ||
### Sublime Text | ||
@@ -200,6 +246,11 @@ Using **[Package Control][sublime-1]**, install **[SublimeLinter][sublime-2]** and | ||
#### [Atom](https://atom.io) | ||
### Atom | ||
Install **[linter-js-standard][atom-1]**. | ||
Alternatively, you can install **[linter-js-standard-engine][atom-4]**. 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][atom-5]**. | ||
For automatic formatting, install **[standard-formatter][atom-2]**. For snippets, | ||
@@ -211,22 +262,41 @@ install **[standardjs-snippets][atom-3]**. | ||
[atom-3]: https://atom.io/packages/standardjs-snippets | ||
[atom-4]: https://atom.io/packages/linter-js-standard-engine | ||
[atom-5]: https://github.com/standard/standard-engine | ||
#### [Vim](http://www.vim.org/) | ||
### Visual Studio Code | ||
Install **[Syntastic][vim-1]** and add this line to `.vimrc`: | ||
Install **[vscode-standard][vscode-1]**. (Includes support for automatic formatting.) | ||
For JS snippets, install: **[vscode-standardjs-snippets][vscode-2]**. For React snippets, install **[vscode-react-standard][vscode-3]**. | ||
[vscode-1]: https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard | ||
[vscode-2]: https://marketplace.visualstudio.com/items?itemName=capaj.vscode-standardjs-snippets | ||
[vscode-3]: https://marketplace.visualstudio.com/items?itemName=TimonVS.ReactSnippetsStandard | ||
### Vim | ||
Install **[ale][vim-1]**. And add these lines to your `.vimrc` file. | ||
```vim | ||
let g:syntastic_javascript_checkers = ['standard'] | ||
let g:ale_linters = { | ||
\ 'javascript': ['standard'], | ||
\} | ||
let g:ale_fixers = {'javascript': ['standard']} | ||
``` | ||
For automatic formatting on save, add these two lines to `.vimrc`: | ||
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`: | ||
```vim | ||
autocmd bufwritepost *.js silent !standard --fix % | ||
set autoread | ||
let g:ale_lint_on_save = 1 | ||
let g:ale_fix_on_save = 1 | ||
``` | ||
[vim-1]: https://github.com/scrooloose/syntastic | ||
#### [Emacs](https://www.gnu.org/software/emacs/) | ||
Alternative plugins to consider include [neomake][vim-2] and [syntastic][vim-3], both of which have built-in support for `standard` (though configuration may be necessary). | ||
[vim-1]: https://github.com/w0rp/ale | ||
[vim-2]: https://github.com/neomake/neomake | ||
[vim-3]: https://github.com/vim-syntastic/syntastic | ||
### Emacs | ||
Install **[Flycheck][emacs-1]** and check out the **[manual][emacs-2]** to learn | ||
@@ -238,61 +308,64 @@ how to enable it in your projects. | ||
#### [Brackets](http://brackets.io/) | ||
### Brackets | ||
Search the extension registry for **["Standard Code Style"][brackets-1]**. | ||
Search the extension registry for **["Standard Code Style"][brackets-1]** and click "Install". | ||
[brackets-1]: https://github.com/ishamf/brackets-standard/ | ||
#### [Visual Studio Code](https://code.visualstudio.com/) | ||
### WebStorm (PhpStorm, IntelliJ, RubyMine, JetBrains, etc.) | ||
Install **[vscode-standardjs][vscode-1]**. (Includes support for automatic formatting.) | ||
WebStorm [recently announced native support](https://blog.jetbrains.com/webstorm/2017/01/webstorm-2017-1-eap-171-2272/) | ||
for `standard` directly in the IDE. | ||
For JS snippets, install: **[vscode-standardjs-snippets][vscode-2]**. For React snippets, install **[vscode-react-standard][vscode-3]**. | ||
If you still prefer to configure `standard` manually, [follow this guide][webstorm-1]. This applies to all JetBrains products, including PhpStorm, IntelliJ, RubyMine, etc. | ||
[vscode-1]: https://marketplace.visualstudio.com/items/chenxsan.vscode-standardjs | ||
[vscode-2]: https://marketplace.visualstudio.com/items?itemName=capaj.vscode-standardjs-snippets | ||
[vscode-3]: https://marketplace.visualstudio.com/items/TimonVS.ReactSnippetsStandard | ||
[webstorm-1]: docs/webstorm.md | ||
#### [WebStorm/PhpStorm][webstorm-1] | ||
## Is there a readme badge? | ||
Both WebStorm and PhpStorm can be [configured for Standard Style][webstorm-2]. | ||
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. | ||
[webstorm-1]: https://www.jetbrains.com/webstorm/ | ||
[webstorm-2]: https://github.com/feross/standard/blob/master/docs/webstorm.md | ||
[](https://github.com/standard/standard) | ||
## FAQ | ||
```md | ||
[](https://github.com/standard/standard) | ||
``` | ||
### Why would I use JavaScript Standard Style? | ||
[](https://standardjs.com) | ||
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! | ||
```md | ||
[](https://standardjs.com) | ||
``` | ||
This module saves you time in two ways: | ||
## I disagree with rule X, can you change it? | ||
- **No configuration.** The easiest way to enforce consistent style in your | ||
project. Just drop it in. | ||
- **Catch style errors before they're submitted in PRs.** Saves precious code | ||
review time by eliminating back-and-forth between maintainer and contributor. | ||
No. The whole point of `standard` is to save you time by avoiding | ||
[bikeshedding][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. | ||
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. | ||
There are a couple of similar packages for anyone who does not want to completely accept `standard`: | ||
- [semistandard](https://github.com/standard/semistandard) - standard, with semicolons | ||
- [standardx](https://github.com/standard/standardx) - standard, with custom tweaks | ||
### I disagree with rule X, can you change it? | ||
If you really want to configure hundreds of ESLint rules individually, you can | ||
always use `eslint` directly with | ||
[eslint-config-standard](https://github.com/standard/eslint-config-standard) to | ||
layer your changes on top. | ||
[`standard-eject`](https://github.com/josephfrazier/standard-eject) can help | ||
you migrate from `standard` to `eslint` and `eslint-config-standard`. | ||
No. The whole point of `standard` is to avoid [bikeshedding][bikeshedding] about | ||
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. | ||
Pro tip: Just use `standard` and move on. There are actual real problems that you | ||
could spend your time solving! :P | ||
[bikeshedding]: https://www.freebsd.org/doc/en/books/faq/misc.html#bikeshed-painting | ||
### But this isn't a real web standard! | ||
## 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 `feross/standard` and not | ||
standards groups, which is why this repo is called `standard/standard` and not | ||
`ECMA/standard`. | ||
@@ -305,20 +378,21 @@ | ||
### Is there an automatic formatter? | ||
## Is there an automatic formatter? | ||
Yes! You can use `standard --fix` to automatically fix most issues automatically. | ||
Yes! You can use `standard --fix` to fix most issues automatically. | ||
`standard --fix` is built into `standard` (since v8.0.0) for maximum convenience. | ||
Lots of problems are fixable, but some errors, like forgetting to handle the error | ||
in node-style callbacks, must be fixed manually. | ||
`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 a message ("Run `standard --fix` to | ||
automatically fix some problems.") when it detects problems that can be fixed | ||
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? | ||
## How do I ignore files? | ||
The paths `node_modules/**`, `*.min.js`, `bundle.js`, `coverage/**`, hidden | ||
files/folders (beginning with `.`), and all patterns in a project's root | ||
`.gitignore` file are automatically ignored. | ||
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 | ||
@@ -338,9 +412,9 @@ that, add a `standard.ignore` property to `package.json`: | ||
### How do I hide a certain warning? | ||
## How do I disable a rule? | ||
In rare cases, you'll need to break a rule and hide the warning generated by | ||
In rare cases, you'll need to break a rule and hide the error generated by | ||
`standard`. | ||
JavaScript Standard Style uses [`eslint`](http://eslint.org/) under-the-hood and | ||
you can hide warnings as you normally would if you used `eslint` directly. | ||
JavaScript Standard Style uses [ESLint](http://eslint.org/) under-the-hood and | ||
you can hide errors as you normally would if you used ESLint directly. | ||
@@ -377,6 +451,6 @@ To get verbose output (so you can find the particular rule name to ignore), run: | ||
### I use a library that pollutes the global namespace. How do I prevent "variable is not defined" errors? | ||
## 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 | ||
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 | ||
@@ -389,9 +463,15 @@ not defined (usually, this rule is really useful for catching typos!). But we want | ||
``` | ||
```js | ||
/* global myVar1, myVar2 */ | ||
``` | ||
If you have hundreds of files, adding comments to every file can be tedious. In | ||
these cases, you can add this to `package.json`: | ||
If you have hundreds of files, it may be desirable to avoid adding comments to | ||
every file. In this case, run: | ||
```bash | ||
$ standard --global myVar1 --global myVar2 | ||
``` | ||
Or, add this to `package.json`: | ||
```json | ||
@@ -405,14 +485,31 @@ { | ||
### Can I use a custom JS parser for bleeding-edge ES next support? | ||
*Note: `global` and `globals` are equivalent.* | ||
Before you use a custom parser, consider whether the added complexity in your | ||
build process is worth it. | ||
## How do I use experimental JavaScript (ES Next) features? | ||
`standard` supports custom JS parsers. To use a custom parser, install it from npm | ||
(example: `npm install babel-eslint`) and add this to your `package.json`: | ||
`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: | ||
```bash | ||
npm install @babel/eslint-parser --save-dev | ||
``` | ||
Then run: | ||
```bash | ||
$ standard --parser @babel/eslint-parser | ||
``` | ||
Or, add this to `package.json`: | ||
```json | ||
{ | ||
"standard": { | ||
"parser": "babel-eslint" | ||
"parser": "@babel/eslint-parser" | ||
} | ||
@@ -422,23 +519,37 @@ } | ||
If you're using `standard` globally (you installed it with `-g`), then you also | ||
need to install `babel-eslint` globally with `npm install babel-eslint -g`. | ||
## Can I use a JavaScript language variant, like Flow or TypeScript? | ||
### Can I use a JavaScript language variant, like Flow? | ||
`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. | ||
Before you use a custom JS language variant, consider whether the added complexity | ||
in your build process (and effort required to get new contributors up-to-speed) is | ||
worth it. | ||
For TypeScript, an official variant `ts-standard` is supported and maintained that provides a very | ||
similar experience to `standard`. | ||
`standard` supports ESLint plugins. Use one of these to transform your code into | ||
valid JavaScript before `standard` sees it. To use a custom parser, install it from | ||
npm (example: `npm install eslint-plugin-flowtype`) and add this to your | ||
`package.json`: | ||
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`](https://github.com/standard/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`. | ||
```bash | ||
npm install ts-standard --save-dev | ||
``` | ||
Then run (where `tsconfig.json` is located in the working directory): | ||
```bash | ||
$ ts-standard | ||
``` | ||
Or, add this to `package.json`: | ||
```json | ||
{ | ||
"standard": { | ||
"parser": "babel-eslint", | ||
"plugins": [ | ||
"flowtype" | ||
] | ||
"ts-standard": { | ||
"project": "./tsconfig.json" | ||
} | ||
@@ -448,33 +559,39 @@ } | ||
If you're using `standard` globally (you installed it with `-g`), then you also | ||
need to install `eslint-plugin-flowtype` globally with | ||
`npm install eslint-plugin-flowtype -g`. | ||
*Note: To include additional files in linting such as test files, create a `tsconfig.eslint.json` file to use instead.* | ||
### Can you make rule X configurable? | ||
If you really want to configure hundreds of ESLint rules individually, you can always use eslint | ||
directly with [`eslint-config-standard-with-typescript`](https://github.com/standard/eslint-config-standard-with-typescript) | ||
to layer your changes on top. | ||
No. The point of `standard` is to save you time by picking reasonable rules so you | ||
can spend your time solving actual problems. If you really do want to configure | ||
hundreds of eslint rules individually, you can always use `eslint` directly. | ||
### Flow | ||
If you just want to tweak a couple rules, consider using | ||
[this shareable config](https://github.com/feross/eslint-config-standard) and | ||
layering your changes on top. | ||
To use Flow, you need to run `standard` with `@babel/eslint-parser` as the parser and | ||
`eslint-plugin-flowtype` as a plugin. | ||
Pro tip: Just use `standard` and move on. There are actual real problems that you | ||
could spend your time solving! :P | ||
```bash | ||
npm install @babel/eslint-parser eslint-plugin-flowtype --save-dev | ||
``` | ||
### What about Web Workers? | ||
Then run: | ||
Add this to the top of your files: | ||
```bash | ||
$ standard --parser @babel/eslint-parser --plugin flowtype | ||
``` | ||
```js | ||
/* eslint-env serviceworker */ | ||
Or, add this to `package.json`: | ||
```json | ||
{ | ||
"standard": { | ||
"parser": "@babel/eslint-parser", | ||
"plugins": [ "flowtype" ] | ||
} | ||
} | ||
``` | ||
This lets `standard` (as well as humans reading your code) know that `self` is a | ||
global in web worker code. | ||
*Note: `plugin` and `plugins` are equivalent.* | ||
### What about Mocha, Jasmine, QUnit, etc? | ||
## What about Mocha, Jest, Jasmine, QUnit, etc? | ||
To support mocha in your test files, add this to the beginning of your test files: | ||
To support mocha in test files, add this to the top of the test files: | ||
@@ -485,3 +602,9 @@ ```js | ||
Where `mocha` can be one of `jasmine`, `qunit`, `phantomjs`, and so on. To see a | ||
Or, run: | ||
```bash | ||
$ standard --env mocha | ||
``` | ||
Where `mocha` can be one of `jest`, `jasmine`, `qunit`, `phantomjs`, and so on. To see a | ||
full list, check ESLint's | ||
@@ -494,31 +617,136 @@ [specifying environments](http://eslint.org/docs/user-guide/configuring.html#specifying-environments) | ||
### Is there a Git `pre-commit` hook? | ||
*Note: `env` and `envs` are equivalent.* | ||
Funny you should ask! | ||
## What about Web Workers and Service Workers? | ||
```sh | ||
#!/bin/sh | ||
# Ensure all javascript files staged for commit pass standard code style | ||
git diff --name-only --cached --relative | grep '\.jsx\?$' | xargs standard | ||
if [ $? -ne 0 ]; then exit 1; fi | ||
Add this to the top of web worker files: | ||
```js | ||
/* eslint-env worker */ | ||
``` | ||
Alternatively, [overcommit](https://github.com/brigade/overcommit) is a Git hook | ||
manager that includes support for running `standard` as a Git pre-commit hook. | ||
To enable this, add the following to your `.overcommit.yml` file: | ||
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: | ||
```js | ||
/* 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](#is-there-an-automatic-formatter). | ||
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](#how-do-i-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`](https://www.npmjs.com/package/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: | ||
```bash | ||
$ npm install eslint-plugin-markdown | ||
``` | ||
Then, to check JS that appears inside code blocks, run: | ||
```bash | ||
$ standard --plugin markdown '**/*.md' | ||
``` | ||
To check code inside HTML files, use an ESLint plugin: | ||
```bash | ||
$ npm install eslint-plugin-html | ||
``` | ||
Then, to check JS that appears inside `<script>` tags, run: | ||
```bash | ||
$ 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 | ||
```bash | ||
#!/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](https://pre-commit.com/) 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`, `.ts`, `.tsx`, `.mjs` and `.cjs` files: | ||
```yaml | ||
PreCommit: | ||
Standard: | ||
enabled: true | ||
- repo: https://github.com/standard/standard | ||
rev: master | ||
hooks: | ||
- id: standard | ||
``` | ||
### How do I make the output all colorful and *pretty*? | ||
Alternatively, for more advanced styling configurations, use `standard` within the [eslint hook](https://github.com/pre-commit/mirrors-eslint): | ||
```yaml | ||
- 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](https://www.npmjs.com/package/snazzy): | ||
```bash | ||
$ npm install snazzy | ||
``` | ||
npm install snazzy | ||
``` | ||
@@ -536,21 +764,29 @@ And run: | ||
## Node.js API | ||
## Is there a Node.js API? | ||
Yes! | ||
### `standard.lintText(text, [opts], callback)` | ||
Lint the provided source `text` to enforce JavaScript Standard Style. An `opts` object may | ||
be provided: | ||
Lint the provided source `text`. An `opts` object may be provided: | ||
```js | ||
var opts = { | ||
{ | ||
cwd: '', // current working directory (default: process.cwd()) | ||
filename: '', // path of the file containing the text being linted (optional, though some eslint plugins require it) | ||
fix: false, // automatically fix problems | ||
globals: [], // global variables to declare | ||
plugins: [], // eslint plugins | ||
envs: [], // eslint environment | ||
parser: '' // js parser (e.g. babel-eslint) | ||
globals: [], // custom global variables to declare | ||
plugins: [], // custom eslint plugins | ||
envs: [], // custom eslint environment | ||
parser: '' // custom js parser (e.g. @babel/eslint-parser) | ||
} | ||
``` | ||
The `callback` will be called with an `Error` and `results` object: | ||
Additional options may be loaded from a `package.json` if it's found for the | ||
current working directory. | ||
The `callback` will be called with an `Error` and `results` object. | ||
The `results` object will contain the following properties: | ||
```js | ||
@@ -565,3 +801,4 @@ var results = { | ||
errorCount: 0, | ||
warningCount: 0 | ||
warningCount: 0, | ||
output: '' // fixed source code (only present with {fix: true} option) | ||
} | ||
@@ -574,2 +811,7 @@ ], | ||
### `results = standard.lintTextSync(text, [opts])` | ||
Synchronous version of `standard.lintText()`. If an error occurs, an exception is | ||
thrown. Otherwise, a `results` object is returned. | ||
### `standard.lintFiles(files, [opts], callback)` | ||
@@ -587,3 +829,3 @@ | ||
envs: [], // eslint environment | ||
parser: '' // js parser (e.g. babel-eslint) | ||
parser: '' // js parser (e.g. @babel/eslint-parser) | ||
} | ||
@@ -594,29 +836,31 @@ ``` | ||
## IRC channel | ||
## How do I contribute to StandardJS? | ||
Join us in `#standard` on freenode. | ||
Contributions are welcome! Check out the [issues](https://github.com/standard/standard/issues) or the [PRs](https://github.com/standard/standard/pulls), and make your own if you want something that you don't see there. | ||
## Contribute | ||
Want to chat? Join contributors on IRC in the `#standard` channel on freenode. | ||
Contributions are welcome! Check out the [issues](https://github.com/feross/standard/issues) or the [PRs](https://github.com/feross/standard/pulls), and make your own if you want something that you don't see there. | ||
Here are some important packages in the `standard` ecosystem: | ||
### I want to contribute to `standard`. What packages should I know about? | ||
- **[standard](https://github.com/feross/standard)** - this repo | ||
- **[standard-engine](https://github.com/flet/standard-engine)** - cli engine for arbitrary eslint rules | ||
- **[eslint-config-standard](https://github.com/feross/eslint-config-standard)** - eslint rules for standard | ||
- **[eslint-config-standard-jsx](https://github.com/feross/eslint-config-standard-jsx)** - eslint rules for standard (JSX) | ||
- **[eslint-plugin-standard](https://github.com/xjamundx/eslint-plugin-standard)** - custom eslint rules for standard (not part of eslint core) | ||
- **[standard](https://github.com/standard/standard)** - this repo | ||
- **[standard-engine](https://github.com/standard/standard-engine)** - cli engine for arbitrary eslint rules | ||
- **[eslint-config-standard](https://github.com/standard/eslint-config-standard)** - eslint rules for standard | ||
- **[eslint-config-standard-jsx](https://github.com/standard/eslint-config-standard-jsx)** - eslint rules for standard (JSX) | ||
- **[eslint](https://github.com/eslint/eslint)** - the linter that powers standard | ||
- **[snazzy](https://github.com/feross/snazzy)** - pretty terminal output for standard | ||
- **[standard-www](https://github.com/feross/standard-www)** - code for http://standardjs.com | ||
- **[semistandard](https://github.com/Flet/semistandard)** - standard, with semicolons (if you must) | ||
- **[snazzy](https://github.com/standard/snazzy)** - pretty terminal output for standard | ||
- **[standard-www](https://github.com/standard/standard-www)** - code for https://standardjs.com | ||
- **[semistandard](https://github.com/standard/semistandard)** - standard, with semicolons (if you must) | ||
- **[standardx](https://github.com/standard/standardx)** - standard, with custom tweaks | ||
There are also many **[editor plugins](#text-editor-plugins)**, a list of | ||
**[npm packages that use `standard`](https://github.com/feross/standard-packages)**, | ||
There are also many **[editor plugins](#are-there-text-editor-plugins)**, a list of | ||
**[npm packages that use `standard`](https://github.com/standard/standard-packages)**, | ||
and an awesome list of | ||
**[packages in the `standard` ecosystem](https://github.com/feross/awesome-standard)**. | ||
**[packages in the `standard` ecosystem](https://github.com/standard/awesome-standard)**. | ||
## Security Policies and Procedures | ||
The `standard` team and community take all security bugs in `standard` seriously. Please see our [security policies and procedures](https://github.com/standard/.github/blob/master/SECURITY.md) document to learn how to report issues. | ||
## License | ||
[MIT](LICENSE). Copyright (c) [Feross Aboukhadijeh](http://feross.org). | ||
[MIT](LICENSE). Copyright (c) [Feross Aboukhadijeh](https://feross.org). |
1204
RULES.md
# JavaScript Standard Style | ||
[](https://github.com/feross/standard) | ||
<p align="center"> | ||
<a href="/docs/RULES-en.md">English</a> • | ||
<a href="/docs/RULES-esla.md">Español (Latinoamérica)</a> • | ||
<a href="/docs/RULES-fr.md">Français</a> • | ||
<a href="/docs/RULES-id.md">Bahasa Indonesia</a> • | ||
<a href="/docs/RULES-iteu.md">Italiano (Italian)</a> • | ||
<a href="/docs/RULES-ja.md">日本語 (Japanese)</a> • | ||
<a href="/docs/RULES-kokr.md">한국어 (Korean)</a> • | ||
<a href="/docs/RULES-ptbr.md">Português (Brasil)</a> • | ||
<a href="/docs/RULES-zhcn.md">简体中文 (Simplified Chinese)</a> • | ||
<a href="/docs/RULES-zhtw.md">繁體中文 (Taiwanese Mandarin)</a> | ||
</p> | ||
This is a TL;DR of the [standard](https://github.com/feross/standard) JavaScript | ||
[](https://github.com/standard/standard) | ||
This is a summary of the [standard](https://github.com/standard/standard) JavaScript | ||
rules. | ||
@@ -15,2 +28,4 @@ | ||
eslint: [`indent`](http://eslint.org/docs/rules/indent) | ||
```js | ||
@@ -24,5 +39,11 @@ function hello (name) { | ||
eslint: [`quotes`](http://eslint.org/docs/rules/quotes) | ||
```js | ||
console.log('hello there') | ||
$("<div class='box'>") | ||
console.log('hello there') // ✓ ok | ||
console.log("hello there") // ✗ avoid | ||
console.log(`hello there`) // ✗ avoid | ||
$("<div class='box'>") // ✓ ok | ||
console.log(`hello ${name}`) // ✓ ok | ||
``` | ||
@@ -32,2 +53,4 @@ | ||
eslint: [`no-unused-vars`](http://eslint.org/docs/rules/no-unused-vars) | ||
```js | ||
@@ -41,2 +64,4 @@ function myFunction () { | ||
eslint: [`keyword-spacing`](http://eslint.org/docs/rules/keyword-spacing) | ||
```js | ||
@@ -49,2 +74,4 @@ if (condition) { ... } // ✓ ok | ||
eslint: [`space-before-function-paren`](http://eslint.org/docs/rules/space-before-function-paren) | ||
```js | ||
@@ -61,2 +88,4 @@ function name (arg) { ... } // ✓ ok | ||
eslint: [`eqeqeq`](http://eslint.org/docs/rules/eqeqeq) | ||
```js | ||
@@ -74,2 +103,4 @@ if (name === 'John') // ✓ ok | ||
eslint: [`space-infix-ops`](http://eslint.org/docs/rules/space-infix-ops) | ||
```js | ||
@@ -89,2 +120,4 @@ // ✓ ok | ||
eslint: [`comma-spacing`](http://eslint.org/docs/rules/comma-spacing) | ||
```js | ||
@@ -104,2 +137,4 @@ // ✓ ok | ||
eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style) | ||
```js | ||
@@ -126,2 +161,4 @@ // ✓ ok | ||
eslint: [`curly`](http://eslint.org/docs/rules/curly) | ||
```js | ||
@@ -147,2 +184,3 @@ // ✓ ok | ||
eslint: [`handle-callback-err`](http://eslint.org/docs/rules/handle-callback-err) | ||
```js | ||
@@ -163,6 +201,20 @@ // ✓ ok | ||
* **Always prefix browser globals** with `window.`.<br> | ||
Exceptions are: `document`, `console` and `navigator`. | ||
* **Declare browser globals** with a `/* global */` comment.<br> | ||
Exceptions are: `window`, `document`, and `navigator`.<br> | ||
Prevents accidental use of poorly-named browser globals like `open`, `length`, | ||
`event`, and `name`. | ||
```js | ||
/* global alert, prompt */ | ||
alert('hi') | ||
prompt('ok?') | ||
``` | ||
Explicitly referencing the function or property on `window` is okay too, though | ||
such code will not run in a Worker which uses `self` instead of `window`. | ||
eslint: [`no-undef`](http://eslint.org/docs/rules/no-undef) | ||
```js | ||
window.alert('hi') // ✓ ok | ||
@@ -173,2 +225,4 @@ ``` | ||
eslint: [`no-multiple-empty-lines`](http://eslint.org/docs/rules/no-multiple-empty-lines) | ||
```js | ||
@@ -183,4 +237,4 @@ // ✓ ok | ||
var value = 'hello world' | ||
// blank line | ||
// blank line | ||
console.log(value) | ||
@@ -191,2 +245,4 @@ ``` | ||
eslint: [`operator-linebreak`](http://eslint.org/docs/rules/operator-linebreak) | ||
```js | ||
@@ -209,2 +265,4 @@ // ✓ ok | ||
eslint: [`one-var`](http://eslint.org/docs/rules/one-var) | ||
```js | ||
@@ -225,2 +283,4 @@ // ✓ ok | ||
eslint: [`no-cond-assign`](http://eslint.org/docs/rules/no-cond-assign) | ||
```js | ||
@@ -237,3 +297,1043 @@ // ✓ ok | ||
``` | ||
* | ||
* **Add spaces inside single line blocks.** | ||
eslint: [`block-spacing`](http://eslint.org/docs/rules/block-spacing) | ||
```js | ||
function foo () {return true} // ✗ avoid | ||
function foo () { return true } // ✓ ok | ||
``` | ||
* **Use camelcase when naming variables and functions.** | ||
eslint: [`camelcase`](http://eslint.org/docs/rules/camelcase) | ||
```js | ||
function my_function () { } // ✗ avoid | ||
function myFunction () { } // ✓ ok | ||
var my_var = 'hello' // ✗ avoid | ||
var myVar = 'hello' // ✓ ok | ||
``` | ||
* **Trailing commas not allowed.** | ||
eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle) | ||
```js | ||
var obj = { | ||
message: 'hello', // ✗ avoid | ||
} | ||
``` | ||
* **Commas must be placed at the end of the current line.** | ||
eslint: [`comma-style`](http://eslint.org/docs/rules/comma-style) | ||
```js | ||
var obj = { | ||
foo: 'foo' | ||
,bar: 'bar' // ✗ avoid | ||
} | ||
var obj = { | ||
foo: 'foo', | ||
bar: 'bar' // ✓ ok | ||
} | ||
``` | ||
* **Dot should be on the same line as property.** | ||
eslint: [`dot-location`](http://eslint.org/docs/rules/dot-location) | ||
```js | ||
console. | ||
log('hello') // ✗ avoid | ||
console | ||
.log('hello') // ✓ ok | ||
``` | ||
* **Files must end with a newline.** | ||
eslint: [`eol-last`](http://eslint.org/docs/rules/eol-last) | ||
* **No space between function identifiers and their invocations.** | ||
eslint: [`func-call-spacing`](http://eslint.org/docs/rules/func-call-spacing) | ||
```js | ||
console.log ('hello') // ✗ avoid | ||
console.log('hello') // ✓ ok | ||
``` | ||
* **Add space between colon and value in key value pairs.** | ||
eslint: [`key-spacing`](http://eslint.org/docs/rules/key-spacing) | ||
```js | ||
var obj = { 'key' : 'value' } // ✗ avoid | ||
var obj = { 'key' :'value' } // ✗ avoid | ||
var obj = { 'key':'value' } // ✗ avoid | ||
var obj = { 'key': 'value' } // ✓ ok | ||
``` | ||
* **Constructor names must begin with a capital letter.** | ||
eslint: [`new-cap`](http://eslint.org/docs/rules/new-cap) | ||
```js | ||
function animal () {} | ||
var dog = new animal() // ✗ avoid | ||
function Animal () {} | ||
var dog = new Animal() // ✓ ok | ||
``` | ||
* **Constructor with no arguments must be invoked with parentheses.** | ||
eslint: [`new-parens`](http://eslint.org/docs/rules/new-parens) | ||
```js | ||
function Animal () {} | ||
var dog = new Animal // ✗ avoid | ||
var dog = new Animal() // ✓ ok | ||
``` | ||
* **Objects must contain a getter when a setter is defined.** | ||
eslint: [`accessor-pairs`](http://eslint.org/docs/rules/accessor-pairs) | ||
```js | ||
var person = { | ||
set name (value) { // ✗ avoid | ||
this._name = value | ||
} | ||
} | ||
var person = { | ||
set name (value) { | ||
this._name = value | ||
}, | ||
get name () { // ✓ ok | ||
return this._name | ||
} | ||
} | ||
``` | ||
* **Constructors of derived classes must call `super`.** | ||
eslint: [`constructor-super`](http://eslint.org/docs/rules/constructor-super) | ||
```js | ||
class Dog { | ||
constructor () { | ||
super() // ✗ avoid | ||
this.legs = 4 | ||
} | ||
} | ||
class Dog extends Animal { | ||
constructor () { // ✗ avoid | ||
this.legs = 4 | ||
} | ||
} | ||
class Dog extends Animal { | ||
constructor () { | ||
super() // ✓ ok | ||
this.legs = 4 | ||
} | ||
} | ||
``` | ||
* **Use array literals instead of array constructors.** | ||
eslint: [`no-array-constructor`](http://eslint.org/docs/rules/no-array-constructor) | ||
```js | ||
var nums = new Array(1, 2, 3) // ✗ avoid | ||
var nums = [1, 2, 3] // ✓ ok | ||
``` | ||
* **Avoid using `arguments.callee` and `arguments.caller`.** | ||
eslint: [`no-caller`](http://eslint.org/docs/rules/no-caller) | ||
```js | ||
function foo (n) { | ||
if (n <= 0) return | ||
arguments.callee(n - 1) // ✗ avoid | ||
} | ||
function foo (n) { | ||
if (n <= 0) return | ||
foo(n - 1) // ✓ ok | ||
} | ||
``` | ||
* **Avoid modifying variables of class declarations.** | ||
eslint: [`no-class-assign`](http://eslint.org/docs/rules/no-class-assign) | ||
```js | ||
class Dog {} | ||
Dog = 'Fido' // ✗ avoid | ||
``` | ||
* **Avoid modifying variables declared using `const`.** | ||
eslint: [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign) | ||
```js | ||
const score = 100 | ||
score = 125 // ✗ avoid | ||
``` | ||
* **Avoid using constant expressions in conditions (except loops).** | ||
eslint: [`no-constant-condition`](http://eslint.org/docs/rules/no-constant-condition) | ||
```js | ||
if (false) { // ✗ avoid | ||
// ... | ||
} | ||
if (x === 0) { // ✓ ok | ||
// ... | ||
} | ||
while (true) { // ✓ ok | ||
// ... | ||
} | ||
``` | ||
* **No control characters in regular expressions.** | ||
eslint: [`no-control-regex`](http://eslint.org/docs/rules/no-control-regex) | ||
```js | ||
var pattern = /\x1f/ // ✗ avoid | ||
var pattern = /\x20/ // ✓ ok | ||
``` | ||
* **No `debugger` statements.** | ||
eslint: [`no-debugger`](http://eslint.org/docs/rules/no-debugger) | ||
```js | ||
function sum (a, b) { | ||
debugger // ✗ avoid | ||
return a + b | ||
} | ||
``` | ||
* **No `delete` operator on variables.** | ||
eslint: [`no-delete-var`](http://eslint.org/docs/rules/no-delete-var) | ||
```js | ||
var name | ||
delete name // ✗ avoid | ||
``` | ||
* **No duplicate arguments in function definitions.** | ||
eslint: [`no-dupe-args`](http://eslint.org/docs/rules/no-dupe-args) | ||
```js | ||
function sum (a, b, a) { // ✗ avoid | ||
// ... | ||
} | ||
function sum (a, b, c) { // ✓ ok | ||
// ... | ||
} | ||
``` | ||
* **No duplicate name in class members.** | ||
eslint: [`no-dupe-class-members`](http://eslint.org/docs/rules/no-dupe-class-members) | ||
```js | ||
class Dog { | ||
bark () {} | ||
bark () {} // ✗ avoid | ||
} | ||
``` | ||
* **No duplicate keys in object literals.** | ||
eslint: [`no-dupe-keys`](http://eslint.org/docs/rules/no-dupe-keys) | ||
```js | ||
var user = { | ||
name: 'Jane Doe', | ||
name: 'John Doe' // ✗ avoid | ||
} | ||
``` | ||
* **No duplicate `case` labels in `switch` statements.** | ||
eslint: [`no-duplicate-case`](http://eslint.org/docs/rules/no-duplicate-case) | ||
```js | ||
switch (id) { | ||
case 1: | ||
// ... | ||
case 1: // ✗ avoid | ||
} | ||
``` | ||
* **Use a single import statement per module.** | ||
eslint: [`no-duplicate-imports`](http://eslint.org/docs/rules/no-duplicate-imports) | ||
```js | ||
import { myFunc1 } from 'module' | ||
import { myFunc2 } from 'module' // ✗ avoid | ||
import { myFunc1, myFunc2 } from 'module' // ✓ ok | ||
``` | ||
* **No empty character classes in regular expressions.** | ||
eslint: [`no-empty-character-class`](http://eslint.org/docs/rules/no-empty-character-class) | ||
```js | ||
const myRegex = /^abc[]/ // ✗ avoid | ||
const myRegex = /^abc[a-z]/ // ✓ ok | ||
``` | ||
* **No empty destructuring patterns.** | ||
eslint: [`no-empty-pattern`](http://eslint.org/docs/rules/no-empty-pattern) | ||
```js | ||
const { a: {} } = foo // ✗ avoid | ||
const { a: { b } } = foo // ✓ ok | ||
``` | ||
* **No using `eval()`.** | ||
eslint: [`no-eval`](http://eslint.org/docs/rules/no-eval) | ||
```js | ||
eval( "var result = user." + propName ) // ✗ avoid | ||
var result = user[propName] // ✓ ok | ||
``` | ||
* **No reassigning exceptions in `catch` clauses.** | ||
eslint: [`no-ex-assign`](http://eslint.org/docs/rules/no-ex-assign) | ||
```js | ||
try { | ||
// ... | ||
} catch (e) { | ||
e = 'new value' // ✗ avoid | ||
} | ||
try { | ||
// ... | ||
} catch (e) { | ||
const newVal = 'new value' // ✓ ok | ||
} | ||
``` | ||
* **No extending native objects.** | ||
eslint: [`no-extend-native`](http://eslint.org/docs/rules/no-extend-native) | ||
```js | ||
Object.prototype.age = 21 // ✗ avoid | ||
``` | ||
* **Avoid unnecessary function binding.** | ||
eslint: [`no-extra-bind`](http://eslint.org/docs/rules/no-extra-bind) | ||
```js | ||
const name = function () { | ||
getName() | ||
}.bind(user) // ✗ avoid | ||
const name = function () { | ||
this.getName() | ||
}.bind(user) // ✓ ok | ||
``` | ||
* **Avoid unnecessary boolean casts.** | ||
eslint: [`no-extra-boolean-cast`](http://eslint.org/docs/rules/no-extra-boolean-cast) | ||
```js | ||
const result = true | ||
if (!!result) { // ✗ avoid | ||
// ... | ||
} | ||
const result = true | ||
if (result) { // ✓ ok | ||
// ... | ||
} | ||
``` | ||
* **No unnecessary parentheses around function expressions.** | ||
eslint: [`no-extra-parens`](http://eslint.org/docs/rules/no-extra-parens) | ||
```js | ||
const myFunc = (function () { }) // ✗ avoid | ||
const myFunc = function () { } // ✓ ok | ||
``` | ||
* **Use `break` to prevent fallthrough in `switch` cases.** | ||
eslint: [`no-fallthrough`](http://eslint.org/docs/rules/no-fallthrough) | ||
```js | ||
switch (filter) { | ||
case 1: | ||
doSomething() // ✗ avoid | ||
case 2: | ||
doSomethingElse() | ||
} | ||
switch (filter) { | ||
case 1: | ||
doSomething() | ||
break // ✓ ok | ||
case 2: | ||
doSomethingElse() | ||
} | ||
switch (filter) { | ||
case 1: | ||
doSomething() | ||
// fallthrough // ✓ ok | ||
case 2: | ||
doSomethingElse() | ||
} | ||
``` | ||
* **No floating decimals.** | ||
eslint: [`no-floating-decimal`](http://eslint.org/docs/rules/no-floating-decimal) | ||
```js | ||
const discount = .5 // ✗ avoid | ||
const discount = 0.5 // ✓ ok | ||
``` | ||
* **Avoid reassigning function declarations.** | ||
eslint: [`no-func-assign`](http://eslint.org/docs/rules/no-func-assign) | ||
```js | ||
function myFunc () { } | ||
myFunc = myOtherFunc // ✗ avoid | ||
``` | ||
* **No reassigning read-only global variables.** | ||
eslint: [`no-global-assign`](http://eslint.org/docs/rules/no-global-assign) | ||
```js | ||
window = {} // ✗ avoid | ||
``` | ||
* **No implied `eval()`.** | ||
eslint: [`no-implied-eval`](http://eslint.org/docs/rules/no-implied-eval) | ||
```js | ||
setTimeout("alert('Hello world')") // ✗ avoid | ||
setTimeout(function () { alert('Hello world') }) // ✓ ok | ||
``` | ||
* **No function declarations in nested blocks.** | ||
eslint: [`no-inner-declarations`](http://eslint.org/docs/rules/no-inner-declarations) | ||
```js | ||
if (authenticated) { | ||
function setAuthUser () {} // ✗ avoid | ||
} | ||
``` | ||
* **No invalid regular expression strings in `RegExp` constructors.** | ||
eslint: [`no-invalid-regexp`](http://eslint.org/docs/rules/no-invalid-regexp) | ||
```js | ||
RegExp('[a-z') // ✗ avoid | ||
RegExp('[a-z]') // ✓ ok | ||
``` | ||
* **No irregular whitespace.** | ||
eslint: [`no-irregular-whitespace`](http://eslint.org/docs/rules/no-irregular-whitespace) | ||
```js | ||
function myFunc () /*<NBSP>*/{} // ✗ avoid | ||
``` | ||
* **No using `__iterator__`.** | ||
eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator) | ||
```js | ||
Foo.prototype.__iterator__ = function () {} // ✗ avoid | ||
``` | ||
* **No labels that share a name with an in scope variable.** | ||
eslint: [`no-label-var`](http://eslint.org/docs/rules/no-label-var) | ||
```js | ||
var score = 100 | ||
function game () { | ||
score: while (true) { // ✗ avoid | ||
score -= 10 | ||
if (score > 0) continue score | ||
break | ||
} | ||
} | ||
``` | ||
* **No label statements.** | ||
eslint: [`no-labels`](http://eslint.org/docs/rules/no-labels) | ||
```js | ||
label: | ||
while (true) { | ||
break label // ✗ avoid | ||
} | ||
``` | ||
* **No unnecessary nested blocks.** | ||
eslint: [`no-lone-blocks`](http://eslint.org/docs/rules/no-lone-blocks) | ||
```js | ||
function myFunc () { | ||
{ // ✗ avoid | ||
myOtherFunc() | ||
} | ||
} | ||
function myFunc () { | ||
myOtherFunc() // ✓ ok | ||
} | ||
``` | ||
* **Avoid mixing spaces and tabs for indentation.** | ||
eslint: [`no-mixed-spaces-and-tabs`](http://eslint.org/docs/rules/no-mixed-spaces-and-tabs) | ||
* **Do not use multiple spaces except for indentation.** | ||
eslint: [`no-multi-spaces`](http://eslint.org/docs/rules/no-multi-spaces) | ||
```js | ||
const id = 1234 // ✗ avoid | ||
const id = 1234 // ✓ ok | ||
``` | ||
* **No multiline strings.** | ||
eslint: [`no-multi-str`](http://eslint.org/docs/rules/no-multi-str) | ||
```js | ||
const message = 'Hello \ | ||
world' // ✗ avoid | ||
``` | ||
* **No `new` without assigning object to a variable.** | ||
eslint: [`no-new`](http://eslint.org/docs/rules/no-new) | ||
```js | ||
new Character() // ✗ avoid | ||
const character = new Character() // ✓ ok | ||
``` | ||
* **No using the `Function` constructor.** | ||
eslint: [`no-new-func`](http://eslint.org/docs/rules/no-new-func) | ||
```js | ||
var sum = new Function('a', 'b', 'return a + b') // ✗ avoid | ||
``` | ||
* **No using the `Object` constructor.** | ||
eslint: [`no-new-object`](http://eslint.org/docs/rules/no-new-object) | ||
```js | ||
let config = new Object() // ✗ avoid | ||
``` | ||
* **No using `new require`.** | ||
eslint: [`no-new-require`](http://eslint.org/docs/rules/no-new-require) | ||
```js | ||
const myModule = new require('my-module') // ✗ avoid | ||
``` | ||
* **No using the `Symbol` constructor.** | ||
eslint: [`no-new-symbol`](http://eslint.org/docs/rules/no-new-symbol) | ||
```js | ||
const foo = new Symbol('foo') // ✗ avoid | ||
``` | ||
* **No using primitive wrapper instances.** | ||
eslint: [`no-new-wrappers`](http://eslint.org/docs/rules/no-new-wrappers) | ||
```js | ||
const message = new String('hello') // ✗ avoid | ||
``` | ||
* **No calling global object properties as functions.** | ||
eslint: [`no-obj-calls`](http://eslint.org/docs/rules/no-obj-calls) | ||
```js | ||
const math = Math() // ✗ avoid | ||
``` | ||
* **No octal literals.** | ||
eslint: [`no-octal`](http://eslint.org/docs/rules/no-octal) | ||
```js | ||
const octal = 042 // ✗ avoid | ||
const decimal = 34 // ✓ ok | ||
const octalString = '042' // ✓ ok | ||
``` | ||
* **No octal escape sequences in string literals.** | ||
eslint: [`no-octal-escape`](http://eslint.org/docs/rules/no-octal-escape) | ||
```js | ||
const copyright = 'Copyright \251' // ✗ avoid | ||
``` | ||
* **Avoid string concatenation when using `__dirname` and `__filename`.** | ||
eslint: [`no-path-concat`](http://eslint.org/docs/rules/no-path-concat) | ||
```js | ||
const pathToFile = __dirname + '/app.js' // ✗ avoid | ||
const pathToFile = path.join(__dirname, 'app.js') // ✓ ok | ||
``` | ||
* **Avoid using `__proto__`.** Use `getPrototypeOf` instead. | ||
eslint: [`no-proto`](http://eslint.org/docs/rules/no-proto) | ||
```js | ||
const foo = obj.__proto__ // ✗ avoid | ||
const foo = Object.getPrototypeOf(obj) // ✓ ok | ||
``` | ||
* **No redeclaring variables.** | ||
eslint: [`no-redeclare`](http://eslint.org/docs/rules/no-redeclare) | ||
```js | ||
let name = 'John' | ||
let name = 'Jane' // ✗ avoid | ||
let name = 'John' | ||
name = 'Jane' // ✓ ok | ||
``` | ||
* **Avoid multiple spaces in regular expression literals.** | ||
eslint: [`no-regex-spaces`](http://eslint.org/docs/rules/no-regex-spaces) | ||
```js | ||
const regexp = /test value/ // ✗ avoid | ||
const regexp = /test {3}value/ // ✓ ok | ||
const regexp = /test value/ // ✓ ok | ||
``` | ||
* **Assignments in return statements must be surrounded by parentheses.** | ||
eslint: [`no-return-assign`](http://eslint.org/docs/rules/no-return-assign) | ||
```js | ||
function sum (a, b) { | ||
return result = a + b // ✗ avoid | ||
} | ||
function sum (a, b) { | ||
return (result = a + b) // ✓ ok | ||
} | ||
``` | ||
* **Avoid assigning a variable to itself** | ||
eslint: [`no-self-assign`](http://eslint.org/docs/rules/no-self-assign) | ||
```js | ||
name = name // ✗ avoid | ||
``` | ||
* **Avoid comparing a variable to itself.** | ||
eslint: [`no-self-compare`](http://eslint.org/docs/rules/no-self-compare) | ||
```js | ||
if (score === score) {} // ✗ avoid | ||
``` | ||
* **Avoid using the comma operator.** | ||
eslint: [`no-sequences`](http://eslint.org/docs/rules/no-sequences) | ||
```js | ||
if (doSomething(), !!test) {} // ✗ avoid | ||
``` | ||
* **Restricted names should not be shadowed.** | ||
eslint: [`no-shadow-restricted-names`](http://eslint.org/docs/rules/no-shadow-restricted-names) | ||
```js | ||
let undefined = 'value' // ✗ avoid | ||
``` | ||
* **Sparse arrays are not allowed.** | ||
eslint: [`no-sparse-arrays`](http://eslint.org/docs/rules/no-sparse-arrays) | ||
```js | ||
let fruits = ['apple',, 'orange'] // ✗ avoid | ||
``` | ||
* **Tabs should not be used** | ||
eslint: [`no-tabs`](http://eslint.org/docs/rules/no-tabs) | ||
* **Regular strings must not contain template literal placeholders.** | ||
eslint: [`no-template-curly-in-string`](http://eslint.org/docs/rules/no-template-curly-in-string) | ||
```js | ||
const message = 'Hello ${name}' // ✗ avoid | ||
const message = `Hello ${name}` // ✓ ok | ||
``` | ||
* **`super()` must be called before using `this`.** | ||
eslint: [`no-this-before-super`](http://eslint.org/docs/rules/no-this-before-super) | ||
```js | ||
class Dog extends Animal { | ||
constructor () { | ||
this.legs = 4 // ✗ avoid | ||
super() | ||
} | ||
} | ||
``` | ||
* **Only `throw` an `Error` object.** | ||
eslint: [`no-throw-literal`](http://eslint.org/docs/rules/no-throw-literal) | ||
```js | ||
throw 'error' // ✗ avoid | ||
throw new Error('error') // ✓ ok | ||
``` | ||
* **Whitespace not allowed at end of line.** | ||
eslint: [`no-trailing-spaces`](http://eslint.org/docs/rules/no-trailing-spaces) | ||
* **Initializing to `undefined` is not allowed.** | ||
eslint: [`no-undef-init`](http://eslint.org/docs/rules/no-undef-init) | ||
```js | ||
let name = undefined // ✗ avoid | ||
let name | ||
name = 'value' // ✓ ok | ||
``` | ||
* **No unmodified conditions of loops.** | ||
eslint: [`no-unmodified-loop-condition`](http://eslint.org/docs/rules/no-unmodified-loop-condition) | ||
```js | ||
for (let i = 0; i < items.length; j++) {...} // ✗ avoid | ||
for (let i = 0; i < items.length; i++) {...} // ✓ ok | ||
``` | ||
* **No ternary operators when simpler alternatives exist.** | ||
eslint: [`no-unneeded-ternary`](http://eslint.org/docs/rules/no-unneeded-ternary) | ||
```js | ||
let score = val ? val : 0 // ✗ avoid | ||
let score = val || 0 // ✓ ok | ||
``` | ||
* **No unreachable code after `return`, `throw`, `continue`, and `break` statements.** | ||
eslint: [`no-unreachable`](http://eslint.org/docs/rules/no-unreachable) | ||
```js | ||
function doSomething () { | ||
return true | ||
console.log('never called') // ✗ avoid | ||
} | ||
``` | ||
* **No flow control statements in `finally` blocks.** | ||
eslint: [`no-unsafe-finally`](http://eslint.org/docs/rules/no-unsafe-finally) | ||
```js | ||
try { | ||
// ... | ||
} catch (e) { | ||
// ... | ||
} finally { | ||
return 42 // ✗ avoid | ||
} | ||
``` | ||
* **The left operand of relational operators must not be negated.** | ||
eslint: [`no-unsafe-negation`](http://eslint.org/docs/rules/no-unsafe-negation) | ||
```js | ||
if (!key in obj) {} // ✗ avoid | ||
if (!(key in obj)) {} // ✓ ok | ||
``` | ||
* **Avoid unnecessary use of `.call()` and `.apply()`.** | ||
eslint: [`no-useless-call`](http://eslint.org/docs/rules/no-useless-call) | ||
```js | ||
sum.call(null, 1, 2, 3) // ✗ avoid | ||
``` | ||
* **Avoid using unnecessary computed property keys on objects.** | ||
eslint: [`no-useless-computed-key`](http://eslint.org/docs/rules/no-useless-computed-key) | ||
```js | ||
const user = { ['name']: 'John Doe' } // ✗ avoid | ||
const user = { name: 'John Doe' } // ✓ ok | ||
``` | ||
* **No unnecessary constructor.** | ||
eslint: [`no-useless-constructor`](http://eslint.org/docs/rules/no-useless-constructor) | ||
```js | ||
class Car { | ||
constructor () { // ✗ avoid | ||
} | ||
} | ||
``` | ||
* **No unnecessary use of escape.** | ||
eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape) | ||
```js | ||
let message = 'Hell\o' // ✗ avoid | ||
``` | ||
* **Renaming import, export, and destructured assignments to the same name is not allowed.** | ||
eslint: [`no-useless-rename`](http://eslint.org/docs/rules/no-useless-rename) | ||
```js | ||
import { config as config } from './config' // ✗ avoid | ||
import { config } from './config' // ✓ ok | ||
``` | ||
* **No whitespace before properties.** | ||
eslint: [`no-whitespace-before-property`](http://eslint.org/docs/rules/no-whitespace-before-property) | ||
```js | ||
user .name // ✗ avoid | ||
user.name // ✓ ok | ||
``` | ||
* **No using `with` statements.** | ||
eslint: [`no-with`](http://eslint.org/docs/rules/no-with) | ||
```js | ||
with (val) {...} // ✗ avoid | ||
``` | ||
* **Maintain consistency of newlines between object properties.** | ||
eslint: [`object-property-newline`](http://eslint.org/docs/rules/object-property-newline) | ||
```js | ||
const user = { | ||
name: 'Jane Doe', age: 30, | ||
username: 'jdoe86' // ✗ avoid | ||
} | ||
const user = { name: 'Jane Doe', age: 30, username: 'jdoe86' } // ✓ ok | ||
const user = { | ||
name: 'Jane Doe', | ||
age: 30, | ||
username: 'jdoe86' | ||
} // ✓ ok | ||
``` | ||
* **No padding within blocks.** | ||
eslint: [`padded-blocks`](http://eslint.org/docs/rules/padded-blocks) | ||
```js | ||
if (user) { | ||
// ✗ avoid | ||
const name = getName() | ||
} | ||
if (user) { | ||
const name = getName() // ✓ ok | ||
} | ||
``` | ||
* **No whitespace between spread operators and their expressions.** | ||
eslint: [`rest-spread-spacing`](http://eslint.org/docs/rules/rest-spread-spacing) | ||
```js | ||
fn(... args) // ✗ avoid | ||
fn(...args) // ✓ ok | ||
``` | ||
* **Semicolons must have a space after and no space before.** | ||
eslint: [`semi-spacing`](http://eslint.org/docs/rules/semi-spacing) | ||
```js | ||
for (let i = 0 ;i < items.length ;i++) {...} // ✗ avoid | ||
for (let i = 0; i < items.length; i++) {...} // ✓ ok | ||
``` | ||
* **Must have a space before blocks.** | ||
eslint: [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks) | ||
```js | ||
if (admin){...} // ✗ avoid | ||
if (admin) {...} // ✓ ok | ||
``` | ||
* **No spaces inside parentheses.** | ||
eslint: [`space-in-parens`](http://eslint.org/docs/rules/space-in-parens) | ||
```js | ||
getName( name ) // ✗ avoid | ||
getName(name) // ✓ ok | ||
``` | ||
* **Unary operators must have a space after.** | ||
eslint: [`space-unary-ops`](http://eslint.org/docs/rules/space-unary-ops) | ||
```js | ||
typeof!admin // ✗ avoid | ||
typeof !admin // ✓ ok | ||
``` | ||
* **Use spaces inside comments.** | ||
eslint: [`spaced-comment`](http://eslint.org/docs/rules/spaced-comment) | ||
```js | ||
//comment // ✗ avoid | ||
// comment // ✓ ok | ||
/*comment*/ // ✗ avoid | ||
/* comment */ // ✓ ok | ||
``` | ||
* **No spacing in template strings.** | ||
eslint: [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) | ||
```js | ||
const message = `Hello, ${ name }` // ✗ avoid | ||
const message = `Hello, ${name}` // ✓ ok | ||
``` | ||
* **Use `isNaN()` when checking for `NaN`.** | ||
eslint: [`use-isnan`](http://eslint.org/docs/rules/use-isnan) | ||
```js | ||
if (price === NaN) { } // ✗ avoid | ||
if (isNaN(price)) { } // ✓ ok | ||
``` | ||
* **`typeof` must be compared to a valid string.** | ||
eslint: [`valid-typeof`](http://eslint.org/docs/rules/valid-typeof) | ||
```js | ||
typeof name === 'undefimed' // ✗ avoid | ||
typeof name === 'undefined' // ✓ ok | ||
``` | ||
* **Immediately Invoked Function Expressions (IIFEs) must be wrapped.** | ||
eslint: [`wrap-iife`](http://eslint.org/docs/rules/wrap-iife) | ||
```js | ||
const getName = function () { }() // ✗ avoid | ||
const getName = (function () { }()) // ✓ ok | ||
const getName = (function () { })() // ✓ ok | ||
``` | ||
* **The `*` in `yield*`expressions must have a space before and after.** | ||
eslint: [`yield-star-spacing`](http://eslint.org/docs/rules/yield-star-spacing) | ||
```js | ||
yield* increment() // ✗ avoid | ||
yield * increment() // ✓ ok | ||
``` | ||
* **Avoid Yoda conditions.** | ||
eslint: [`yoda`](http://eslint.org/docs/rules/yoda) | ||
```js | ||
if (42 === age) { } // ✗ avoid | ||
if (age === 42) { } // ✓ ok | ||
``` | ||
## Semicolons | ||
@@ -243,2 +1343,4 @@ | ||
eslint: [`semi`](http://eslint.org/docs/rules/semi) | ||
```js | ||
@@ -249,4 +1351,10 @@ window.alert('hi') // ✓ ok | ||
* Never start a line with `(`, `[`, or `` ` ``. This is the only gotcha with omitting semicolons, and standard protects you from this potential issue. | ||
* Never start a line with `(`, `[`, `` ` ``, or a handful of other unlikely possibilities. | ||
This is the only gotcha with omitting semicolons, and `standard` protects you from this potential issue. | ||
(The full list is: `[`, `(`, `` ` ``, `+`, `*`, `/`, `-`, `,`, `.`, but most of these will never appear at the start of a line in real code.) | ||
eslint: [`no-unexpected-multiline`](http://eslint.org/docs/rules/no-unexpected-multiline) | ||
```js | ||
@@ -291,3 +1399,3 @@ // ✓ ok | ||
This is much preferred: | ||
This is strongly preferred: | ||
@@ -315,43 +1423,41 @@ ```js | ||
[Relying on automatic semicolon insertion] is quite safe, and perfectly valid JS that every browser understands. Closure compiler, yuicompressor, packer, and jsmin all can properly minify it. There is no performance impact anywhere. | ||
> [Relying on automatic semicolon insertion] is quite safe, and perfectly valid JS that every browser understands. Closure compiler, yuicompressor, packer, and jsmin all can properly minify it. There is no performance impact anywhere. | ||
> | ||
> I am sorry that, instead of educating you, the leaders in this language community have given you lies and fear. That was shameful. I recommend learning how statements in JS are actually terminated (and in which cases they are not terminated), so that you can write code that you find beautiful. | ||
> | ||
> In general, `\n` ends a statement unless: | ||
> 1. The statement has an unclosed paren, array literal, or object literal or ends in some | ||
> other way that is not a valid way to end a statement. (For instance, ending with `.` | ||
> or `,`.) | ||
> 2. The line is `--` or `++` (in which case it will decrement/increment the next token.) | ||
> 3. It is a `for()`, `while()`, `do`, `if()`, or `else`, and there is no `{` | ||
> 4. The next line starts with `[`, `(`, `+`, `*`, `/`, `-`, `,`, `.`, or some other | ||
> binary operator that can only be found between two tokens in a single expression. | ||
> | ||
> The first is pretty obvious. Even JSLint is ok with `\n` chars in JSON and parenthesized constructs, and with `var` statements that span multiple lines ending in `,`. | ||
> | ||
> The second is super weird. I’ve never seen a case (outside of these sorts of conversations) where you’d want to do write `i\n++\nj`, but, point of fact, that’s parsed as `i; ++j`, not `i++; j`. | ||
> | ||
> The third is well understood, if generally despised. `if (x)\ny()` is equivalent to `if (x) { y() }`. The construct doesn’t end until it reaches either a block, or a statement. | ||
> | ||
> `;` is a valid JavaScript statement, so `if(x);` is equivalent to `if(x){}` or, “If x, do nothing.” This is more commonly applied to loops where the loop check also is the update function. Unusual, but not unheard of. | ||
> | ||
> The fourth is generally the fud-inducing “oh noes, you need semicolons!” case. But, as it turns out, it’s quite easy to *prefix* those lines with semicolons if you don’t mean them to be continuations of the previous line. For example, instead of this: | ||
> | ||
> ```js | ||
> foo(); | ||
> [1,2,3].forEach(bar); | ||
> ``` | ||
> | ||
> you could do this: | ||
> | ||
> ```js | ||
> foo() | ||
> ;[1,2,3].forEach(bar) | ||
> ``` | ||
> | ||
> The advantage is that the prefixes are easier to notice, once you are accustomed to never seeing lines starting with `(` or `[` without semis. | ||
I am sorry that, instead of educating you, the leaders in this language community have given you lies and fear. That was shameful. I recommend learning how statements in JS are actually terminated (and in which cases they are not terminated), so that you can write code that you find beautiful. | ||
In general, `\n` ends a statement unless: | ||
1. The statement has an unclosed paren, array literal, or object literal or ends in some | ||
other way that is not a valid way to end a statement. (For instance, ending with `.` | ||
or `,`.) | ||
2. The line is `--` or `++` (in which case it will decrement/increment the next token.) | ||
3. It is a `for()`, `while()`, `do`, `if()`, or `else`, and there is no `{` | ||
4. The next line starts with `[`, `(`, `+`, `*`, `/`, `-`, `,`, `.`, or some other | ||
binary operator that can only be found between two tokens in a single expression. | ||
The first is pretty obvious. Even JSLint is ok with `\n` chars in JSON and parenthesized constructs, and with `var` statements that span multiple lines ending in `,`. | ||
The second is super weird. I’ve never seen a case (outside of these sorts of conversations) where you’d want to do write `i\n++\nj`, but, point of fact, that’s parsed as `i; ++j`, not `i++; j`. | ||
The third is well understood, if generally despised. `if (x)\ny()` is equivalent to `if (x) { y() }`. The construct doesn’t end until it reaches either a block, or a statement. | ||
`;` is a valid JavaScript statement, so `if(x);` is equivalent to `if(x){}` or, “If x, do nothing.” This is more commonly applied to loops where the loop check also is the update function. Unusual, but not unheard of. | ||
The fourth is generally the fud-inducing “oh noes, you need semicolons!” case. But, as it turns out, it’s quite easy to *prefix* those lines with semicolons if you don’t mean them to be continuations of the previous line. For example, instead of this: | ||
```js | ||
foo(); | ||
[1,2,3].forEach(bar); | ||
``` | ||
you could do this: | ||
```js | ||
foo() | ||
;[1,2,3].forEach(bar) | ||
``` | ||
The advantage is that the prefixes are easier to notice, once you are accustomed to never seeing lines starting with `(` or `[` without semis. | ||
*End quote from "An Open Letter to JavaScript Leaders Regarding Semicolons".* | ||
[1]: http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding | ||
[2]: http://inimino.org/~inimino/blog/javascript_semicolons | ||
[3]: https://www.youtube.com/watch?v=gsfbh17Ax9I |
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
159195
132.72%846
40.53%0
-100%8
14.29%11
-38.89%31
-82.29%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated