belly-button
Advanced tools
Comparing version 7.0.0 to 8.0.0-beta.0
@@ -7,8 +7,5 @@ 'use strict'; | ||
browser: false, | ||
es6: true, | ||
es2021: true, | ||
node: true | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2020 | ||
}, | ||
reportUnusedDisableDirectives: true, | ||
@@ -38,3 +35,2 @@ rules: { | ||
'getter-return': 'error', | ||
'handle-callback-err': ['error', '^(err|error)$' ], | ||
'indent': ['error', 2, { 'SwitchCase': 1 }], | ||
@@ -47,3 +43,2 @@ 'key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }], | ||
'no-async-promise-executor': 'error', | ||
'no-buffer-constructor': 'error', | ||
'no-caller': 'error', | ||
@@ -87,2 +82,3 @@ 'no-class-assign': 'error', | ||
'no-lone-blocks': 'error', | ||
'no-loss-of-precision': 'error', | ||
'no-misleading-character-class': 'error', | ||
@@ -97,3 +93,2 @@ 'no-mixed-spaces-and-tabs': 'error', | ||
'no-new-symbol': 'error', | ||
'no-new-require': 'error', | ||
'no-new-wrappers': 'error', | ||
@@ -108,3 +103,2 @@ 'no-obj-calls': 'error', | ||
'no-return-assign': 'error', | ||
'no-return-await': 'error', | ||
'no-self-assign': 'error', | ||
@@ -125,4 +119,7 @@ 'no-self-compare': 'error', | ||
'no-unreachable': 'error', | ||
'no-unreachable-loop': 'error', | ||
'no-unsafe-finally': 'error', | ||
'no-unsafe-negation': 'error', | ||
'no-unsafe-optional-chaining': 'error', | ||
'no-unused-expressions': 'error', | ||
'no-unused-vars': ['error', { 'vars': 'all', 'args': 'none' }], | ||
@@ -159,3 +156,3 @@ 'no-use-before-define': ['error', 'nofunc'], | ||
'space-before-blocks': ['error', 'always'], | ||
'space-before-function-paren': ['error', 'always'], | ||
'space-before-function-paren': ['error', { 'anonymous': 'never', 'named': 'never', 'asyncArrow': 'always' }], | ||
'space-in-parens': ['error', 'never'], | ||
@@ -162,0 +159,0 @@ 'space-infix-ops': 'error', |
#!/usr/bin/env node | ||
'use strict'; | ||
require('../lib/cli').run(process.argv, (err, output, code) => { | ||
if (err) { | ||
async function main() { | ||
try { | ||
const [output, code] = await require('../lib/cli').run(process.argv); | ||
console.log(output); | ||
process.exit(code); | ||
} catch (err) { | ||
console.error(err.message); | ||
process.exit(1); | ||
} | ||
} | ||
console.log(output); | ||
process.exit(code); | ||
}); | ||
main(); |
116
lib/cli.js
@@ -5,4 +5,3 @@ 'use strict'; | ||
const Bossy = require('@hapi/bossy'); | ||
const Chalk = require('chalk'); | ||
const { CLIEngine } = require('eslint'); | ||
const { ESLint } = require('eslint'); | ||
const Glob = require('glob'); | ||
@@ -69,95 +68,36 @@ const Insync = require('insync'); | ||
module.exports.run = async function (argv, callback) { | ||
module.exports.run = async function(argv) { | ||
const args = Bossy.parse(cliArgs, { argv }); | ||
if (args instanceof Error) { | ||
return callback(new Error(Bossy.usage(cliArgs, args.message))); | ||
throw new Error(Bossy.usage(cliArgs, args.message)); | ||
} | ||
const configFile = args.config; | ||
const globs = args.input; | ||
const ignore = args.ignore; | ||
const fix = args.fix; | ||
const cache = args.cache; | ||
const cwd = args.pwd || process.cwd(); | ||
try { | ||
const files = await getFilesToLint({ globs, ignore, cwd }); | ||
const result = lintFiles({ configFile, fix, cache, files }); | ||
const exitCode = +!!result.errorCount; | ||
const output = formatResults(result); | ||
callback(null, output, exitCode); | ||
} catch (err) { | ||
callback(err); | ||
} | ||
}; | ||
function formatResults (result) { | ||
const totalWarnings = result.warningCount; | ||
const totalErrors = result.errorCount; | ||
const totalIssues = totalWarnings + totalErrors; | ||
if (totalIssues < 1) { | ||
return Chalk.green.bold('\nNo issues found!\n'); | ||
} | ||
let output = '\n'; | ||
const position = Chalk.gray.bold; | ||
const error = Chalk.red; | ||
const warning = Chalk.yellow; | ||
const colorCode = { | ||
2: error, | ||
1: warning | ||
}; | ||
result.results.forEach((file) => { | ||
if (file.errorCount < 1 && file.warningCount < 1) { | ||
return; | ||
} | ||
output += 'Problems in: ' + Chalk.dim(file.filePath) + '\n'; | ||
file.messages.forEach((msg) => { | ||
const mainStyle = colorCode[msg.severity] || Chalk.gray; | ||
output += mainStyle('\t' + msg.message.slice(0, -1) + | ||
' at line ' + position(Util.format('[%s]', msg.line)) + | ||
', column ' + position(Util.format('[%s]', msg.column))); | ||
output += ' - ' + Chalk.blue(Util.format('(%s)', msg.ruleId)); | ||
output += '\n'; | ||
}); | ||
output += '\n'; | ||
}); | ||
output += Chalk.bold('Results\n'); | ||
output += 'Total ' + error.bold('errors') + ': ' + totalErrors + '\n'; | ||
output += 'Total ' + warning.bold('warnings') + ': ' + totalWarnings; | ||
output += '\n'; | ||
return output; | ||
} | ||
function lintFiles (options) { | ||
const fix = options.fix; | ||
const linter = new CLIEngine({ | ||
configFile: options.configFile, | ||
const files = await getFilesToLint({ globs, ignore, cwd }); | ||
const linter = new ESLint({ | ||
overrideConfigFile: args.config, | ||
useEslintrc: false, | ||
fix, | ||
cache: options.cache | ||
fix: args.fix, | ||
cache: args.cache | ||
}); | ||
const result = await linter.lintFiles(files); | ||
const hasErrors = result.some((current) => { | ||
return current.errorCount > 0; | ||
}); | ||
const result = linter.executeOnFiles(options.files); | ||
if (fix) { | ||
CLIEngine.outputFixes(result); | ||
if (args.fix) { | ||
await ESLint.outputFixes(result); | ||
} | ||
return result; | ||
} | ||
const formatter = await linter.loadFormatter('stylish'); | ||
const output = formatter.format(result); | ||
return [output, +hasErrors]; | ||
}; | ||
function getFiles (options, callback) { | ||
function getFiles(options, callback) { | ||
let files = []; | ||
@@ -170,4 +110,8 @@ const globOptions = { | ||
for (let i = 0; i < globOptions.ignore.length; i++) { | ||
globOptions.ignore[i] = convertWindowsGlobSlashes(globOptions.ignore[i]); | ||
} | ||
Insync.each(options.globs, (pattern, next) => { | ||
Glob(pattern, globOptions, (err, paths) => { | ||
Glob(convertWindowsGlobSlashes(pattern), globOptions, (err, paths) => { | ||
if (err) { | ||
@@ -184,1 +128,11 @@ return next(err); | ||
} | ||
function convertWindowsGlobSlashes(p) { | ||
// Glob only supports forward slashes as glob path separators on Windows. | ||
if (process.platform === 'win32') { | ||
return p.split(Path.sep).join(Path.posix.sep); | ||
} | ||
return p; | ||
} |
{ | ||
"name": "belly-button", | ||
"version": "7.0.0", | ||
"version": "8.0.0-beta.0", | ||
"description": "the best souce of linting", | ||
@@ -20,12 +20,11 @@ "author": "Colin J. Ihrig <cjihrig@gmail.com> (http://www.cjihrig.com/)", | ||
"scripts": { | ||
"lint": "node ./bin/belly-button -I 'test/fixtures/**' -I 'node_modules/**' -f", | ||
"test": "npm run lint && lab -v -t 100" | ||
"lint": "node ./bin/belly-button -I \"test/fixtures/**\" -I \"node_modules/**\" -f", | ||
"test": "npm run lint && lab -v" | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=12.0.0" | ||
}, | ||
"dependencies": { | ||
"@hapi/bossy": "5.x.x", | ||
"chalk": "4.x.x", | ||
"eslint": "7.x.x", | ||
"eslint": "8.0.0-beta.2", | ||
"glob": "7.x.x", | ||
@@ -35,7 +34,6 @@ "insync": "2.x.x" | ||
"devDependencies": { | ||
"@hapi/lab": "22.x.x", | ||
"@hapi/lab": "24.x.x", | ||
"cb-barrier": "1.x.x", | ||
"fs-extra": "9.x.x", | ||
"stand-in": "4.x.x", | ||
"strip-ansi": "6.x.x" | ||
"fs-extra": "10.x.x", | ||
"stand-in": "4.x.x" | ||
}, | ||
@@ -42,0 +40,0 @@ "keywords": [ |
# belly-button | ||
[![Current Version](https://img.shields.io/npm/v/belly-button.svg)](https://www.npmjs.org/package/belly-button) | ||
[![Build Status via Travis CI](https://travis-ci.org/cjihrig/belly-button.svg?branch=master)](https://travis-ci.org/cjihrig/belly-button) | ||
[![belly-button-style](https://img.shields.io/badge/eslint-bellybutton-4B32C3.svg)](https://github.com/cjihrig/belly-button) | ||
@@ -6,0 +5,0 @@ |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4
4
13505
294
1
30
+ Added@eslint-community/eslint-utils@4.4.0(transitive)
+ Added@eslint-community/regexpp@4.10.0(transitive)
+ Added@eslint/config-array@0.15.1(transitive)
+ Added@eslint/eslintrc@1.4.13.1.0(transitive)
+ Added@eslint/js@9.4.0(transitive)
+ Added@eslint/object-schema@2.1.3(transitive)
+ Added@humanwhocodes/config-array@0.6.0(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/retry@0.3.0(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Addedacorn@8.11.3(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedeslint@8.0.0-beta.29.4.0(transitive)
+ Addedeslint-scope@6.0.08.0.1(transitive)
+ Addedeslint-utils@3.0.0(transitive)
+ Addedeslint-visitor-keys@3.4.34.0.0(transitive)
+ Addedespree@10.0.19.6.1(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfile-entry-cache@8.0.0(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedflat-cache@4.0.1(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedglobals@14.0.0(transitive)
+ Addedignore@5.3.1(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedchalk@4.x.x
- Removed@babel/code-frame@7.12.11(transitive)
- Removed@babel/helper-validator-identifier@7.24.6(transitive)
- Removed@babel/highlight@7.24.6(transitive)
- Removed@eslint/eslintrc@0.4.3(transitive)
- Removed@humanwhocodes/config-array@0.5.0(transitive)
- Removedacorn@7.4.1(transitive)
- Removedajv@8.14.0(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedastral-regex@2.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedeslint@7.32.0(transitive)
- Removedeslint-scope@5.1.1(transitive)
- Removedeslint-utils@2.1.0(transitive)
- Removedeslint-visitor-keys@1.3.0(transitive)
- Removedespree@7.3.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedestraverse@4.3.0(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedlodash.truncate@4.4.2(transitive)
- Removedpicocolors@1.0.1(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedslice-ansi@4.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable@6.8.2(transitive)
Updatedeslint@8.0.0-beta.2