Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-formatter-mo

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-formatter-mo - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

117

lib/index.js

@@ -8,67 +8,80 @@ const path = require( 'path' )

module.exports = function ( results ) {
let totalErrorCount = 0
let totalWarningCount = 0
const lines = []
results.forEach( result => {
const {
filePath,
source,
output,
errorCount,
warningCount,
messages = []
} = result
results
.forEach( result => {
const {
filePath,
source,
output,
errorCount,
warningCount,
messages = []
} = result
const errorSummary = errorCount > 0 ?
chalk.red.bold( errorCount + ' ' + plur( 'error', errorCount ) ) :
''
const warningSummary = warningCount > 0 ?
chalk.yellow.bold( warningCount + ' ' + plur( 'warning', warningCount ) ) :
''
totalErrorCount = totalErrorCount + errorCount
totalWarningCount = totalWarningCount + warningCount
const relativePath = path.relative( '.', filePath )
const basename = path.basename( relativePath )
const dirname = path.dirname( relativePath ) + path.sep
let header = '\n ' + chalk.dim( dirname ) + chalk.dim.bold( basename ) +
` 🔥${ errorCount > 0 ? ' ' : '' }` +
[ errorSummary, warningSummary ].join( ' ' ) +
`🔥\n`
const errorSummary = errorCount > 0 ?
chalk.red.bold( errorCount + ' ' + plur( 'error', errorCount ) ) :
''
const warningSummary = warningCount > 0 ?
chalk.yellow.bold(
`${ warningCount } ${ plur( 'warning', warningCount ) }`
) :
''
const divider = chalk.dim( '-'.repeat( stringWidth( header ) ) )
header = divider + header + divider
const relativePath = path.relative( '.', filePath )
const basename = path.basename( relativePath )
const dirname = path.dirname( relativePath ) + path.sep
let header = '\n ' + chalk.dim( dirname ) + chalk.dim.bold( basename ) +
` 🔥${ errorCount > 0 ? ' ' : '' }` +
[ errorSummary, warningSummary ].join( ' ' ) +
`🔥\n`
lines.push( header )
const divider = chalk.dim( '-'.repeat( stringWidth( header ) ) )
header = divider + header + divider
const locations = messages.map( m => {
let { message } = m
lines.push( header )
message = message.replace(
/\B`(.*?)`\B|\B'(.*?)'\B/g,
( m, p1, p2 ) => chalk.bold( p1 || p2 )
)
message = message.replace( /\s+$/, '' )
const locations = messages.map( m => {
let { message } = m
const severity = ( m.fatal || m.severity === 2 || m.severity === 'error' ) ?
'error' :
'warning'
const line = Number( m.line || 0 )
const column = Number( m.column || 0 )
message = message.replace(
/\B`(.*?)`\B|\B'(.*?)'\B/g,
( m, p1, p2 ) => chalk.bold( p1 || p2 )
)
message = message.replace( /\s+$/, '' )
return {
severity,
message,
line,
column,
const severity = ( m.fatal || m.severity === 2 || m.severity === 'error' ) ?
'error' :
'warning'
const line = Number( m.line || 0 )
const column = Number( m.column || 0 )
return {
severity,
message,
line,
column,
}
} )
if ( source || output ) {
try {
const codeframe = locate( source || output, locations )
lines.push( codeframe )
} catch ( e ) {
console.log( e )
}
}
} )
if ( source || output ) {
try {
const codeframe = locate( source || output, locations )
lines.push( codeframe )
} catch ( e ) {
console.log( e )
}
}
} )
if ( totalErrorCount + totalWarningCount > 0 ) {
return '\n' + lines.join( '\n' )
}
return '\n' + lines.join( '\n' )
return ''
}

@@ -24,3 +24,4 @@ const chalk = require( 'chalk' )

'class': chalk.yellow, // eslint-disable-line
'function': chalk.yellow, // eslint-disable-line
'function': chalk.reset.white, // eslint-disable-line
params: chalk.reset.white,
} ).value.split( '\n' )

@@ -44,4 +45,5 @@

tabsToSpaces( str.slice( 0, l.column - 1 ) ).length
) + '└─ ' + ( l.severity === 'warning' ? '⚠' : '✖' ) + ' ' +
l.message
) + '└─ ',
severity: l.severity,
message: l.message
}

@@ -96,4 +98,16 @@ } ).sort( ( a, b ) => {

return chalk.bgBlack( `${ chalk.dim( lineNum + ':' ) } ${ tabsToSpaces( formattedLines[ i ] ) } ` ) +
`\n${ indicators.map( i => chalk.dim( i.content ) ).join( '\n' ) }`
const lineNo = chalk.dim( lineNum + ':' )
const indentation = tabsToSpaces( formattedLines[ i ] )
const display = i => {
if ( i.severity ) {
return chalk.dim( i.content ) +
`${ i.severity === 'warning' ? chalk.yellow.dim( '⚠' ) : chalk.red( '✖' ) } ` +
chalk.dim( i.message )
}
return chalk.dim( i.content )
}
return chalk.bgBlack( `${ lineNo } ${ indentation } ` ) +
`\n${ indicators.map( display ).join( '\n' ) }`
}

@@ -100,0 +114,0 @@

{
"name": "eslint-formatter-mo",
"description": "",
"version": "0.1.0",
"version": "0.1.1",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "files": [

@@ -1,1 +0,25 @@

# eslint-formatter-mo
# eslint-formatter-mo
Good-lookin' ESLint formatter
<img src="media/snapshot.jpg" alt="snapshot" width="500px">
# Installation
```bash
yarn add eslint-formatter-mo --dev
```
or
```bash
npm i eslint-formatter-mo -D
```
# Usage
`eslint [directory] -f mo`
# License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc