提交 0a7e9afc 编写于 作者: F Feross Aboukhadijeh

initial commit

上级 3784242d
{
"disallowKeywordsOnNewLine": ["else"],
"disallowKeywords": ["with"],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowMultipleVarDecl": "exceptUndefined",
"disallowNewlineBeforeBlockStatements": true,
"disallowOperatorBeforeLineBreak": ["."],
"disallowPaddingNewlinesInBlocks": true,
"disallowQuotedKeysInObjects": "allButReserved",
"disallowSemicolons": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"disallowSpacesInCallExpression": true,
"disallowSpacesInsideParentheses": true,
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"disallowYodaConditions": true,
"requireBlocksOnNewline": 1,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireDotNotation": true,
"requireLineFeedAtFileEnd": true,
"requireOperatorBeforeLineBreak": ["=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireParenthesesAroundIIFE": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceAfterKeywords": true,
"requireSpaceAfterLineComment": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeKeywords": ["else", "while", "catch"],
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInConditionalExpression": {
"afterTest": true,
"beforeConsequent": true,
"afterConsequent": true,
"beforeAlternate": true
},
"requireSpacesInForStatement": true,
"requireSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunction": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"safeContextKeyword": ["self"],
"validateIndentation": 2,
"validateLineBreaks": "LF",
"validateParameterSeparator": ", ",
"validateQuoteMarks": {
"mark": "'",
"escape": true
}
}
{
"asi": true,
"browser": true,
"devel": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"globals": {
"chrome": false,
"FileList": false
},
"immed": true,
"latedef": "nofunc",
"laxbreak": true,
"loopfunc": true,
"newcap": true,
"noarg": true,
"node": true,
"predef": [
"escape",
"unescape"
],
"strict": false,
"undef": true
}
language: node_js
node_js:
- '0.10'
- '0.11'
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# standard [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]
[travis-image]: https://img.shields.io/travis/feross/standard.svg?style=flat
[travis-url]: https://travis-ci.org/feross/standard
[npm-image]: https://img.shields.io/npm/v/standard.svg?style=flat
[npm-url]: https://npmjs.org/package/standard
[downloads-image]: https://img.shields.io/npm/dm/standard.svg?style=flat
[downloads-url]: https://npmjs.org/package/standard
### Enforce code style standards
## install
```bash
npm install standard
```
## usage
The easiest way to use `standard` 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):
```bash
npm install standard -g
```
After you've done that you should be able to use the `standard` program. The simplest use
case would be checking the style of all JavaScript files in the current working directory:
```bash
$ standard
Error: Code style check failed:
/Users/feross/code/webtorrent/lib/torrent.js:950:11: Expected '===' and instead saw '=='.
```
### 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-normal-tests.js"
}
}
```
2. Check style automatically when you run `npm test`
```bash
$ npm test
Error: Code style check failed:
/Users/feross/code/webtorrent/lib/torrent.js:950:11: Expected '===' and instead saw '=='.
```
3. Never give style feedback on a pull request again!
## license
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
#!/usr/bin/env node
var standard = require('../')
standard(process.cwd())
var cp = require('child_process')
var find = require('find')
var path = require('path')
var split = require('split')
var JSHINT = path.join(__dirname, 'node_modules', '.bin', 'jshint')
var JSHINTRC = path.join(__dirname, '.jshintrc')
var JSCS = path.join(__dirname, 'node_modules', '.bin', 'jscs')
var JSCSRC = path.join(__dirname, '.jscsrc')
var JSCS_REPORTER = path.join(__dirname, 'jscs-reporter.js')
module.exports = function (dir) {
find.file(/\.js$/, dir || process.cwd(), function (files) {
files = files.filter(function (file) {
return !/\/node_modules\/|\.min.js$/.test(file)
})
var jshintArgs = ['--config', JSHINTRC, '--reporter', 'unix'].concat(files)
var jscsArgs = ['--config', JSCSRC, '--reporter', JSCS_REPORTER].concat(files)
var jshint = spawn(JSHINT, jshintArgs, function (jshintErr) {
var jscs = spawn(JSCS, jscsArgs, function (jscsErr) {
if (jshintErr || jscsErr) {
process.exit(1)
}
})
stderrPipe(jscs.stdout)
stderrPipe(jscs.stderr)
})
stderrPipe(jshint.stdout)
stderrPipe(jshint.stderr)
})
.error(function (err) {
if (err) error(err)
})
}
function spawn (command, args, cb) {
var child = cp.spawn(command, args)
child.on('error', error)
child.on('close', function (code) {
if (code !== 0) cb(new Error('non-zero exit code: ' + code))
else cb(null)
})
return child
}
function error (err) {
console.error(err.stack || err.message || err)
process.exit(1)
}
var errored = false
function stderrPipe (readable) {
readable
.pipe(split())
.on('data', function (line) {
if (line === '') return
if (/^\d+ errors?/.test(line)) return
if (!errored) {
errored = true
console.error('Error: Code style check failed:')
}
console.error(' ' + line)
})
}
var util = require('util')
module.exports = function (errorsCollection) {
var errorCount = 0
errorsCollection.forEach(function (errors) {
var file = errors.getFilename()
if (!errors.isEmpty()) {
errors.getErrorList().forEach(function (error) {
errorCount++
console.log(util.format(
'%s:%d:%d: %s', file, error.line, error.column, error.message
))
})
}
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册