Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
eslint-formatter-friendly
Advanced tools
simple formatter/reporter for eslint that's friendly with Sublime Text and iterm2 'click to open file' functionality
The eslint-formatter-friendly package is a user-friendly formatter for ESLint that provides clear and concise output of linting results. It is designed to make it easier for developers to understand and fix linting issues in their code.
User-Friendly Output
This feature provides a user-friendly output format for ESLint results, making it easier to read and understand the linting issues.
module.exports = {
"extends": "eslint:recommended",
"formatter": "friendly"
};
Integration with ESLint
This feature allows you to use the friendly formatter directly from the command line with ESLint, providing a clear and concise output of linting results.
eslint -f friendly yourfile.js
eslint-formatter-pretty is another ESLint formatter that provides a visually appealing and easy-to-read output. It focuses on making the linting results more readable by using colors and a clean layout. Compared to eslint-formatter-friendly, it emphasizes aesthetics and readability.
eslint-formatter-codeframe is a formatter that displays linting results in a code frame format, similar to Babel's code frame formatter. It highlights the exact lines and columns where issues occur, making it easier to pinpoint problems. This formatter is more focused on providing detailed context for each issue compared to eslint-formatter-friendly.
eslint-formatter-stylish is a popular formatter that provides a stylish and easy-to-read output for ESLint results. It uses colors and a clean layout to present linting issues in a clear and organized manner. While similar to eslint-formatter-friendly, it is more widely used and has a slightly different visual style.
A simple formatter/reporter for ESLint that's friendly with Sublime Text and iterm2 "click to open file" functionality
I decided to use eslint to verify my code and sadly the reporter was not terminal friendly. Basically I cannot click on the file to open it with my text editor and go directly to the line where the error was reported. This module fixes that issue, by using the syntax that "sublime text" introduced to open files.
Filenames may be given a :line or :line:column suffix to open at a specific location.
This module is based on the original stylish
formatter that is now part of ESLint, it adds the following
All the errors are reported at the end, so no more search for errors between tons of report lines
RuleIds are clickable on terminals like iTerm2 and take you to the ruleId documentation site.
A summary is shown at the end with the offended ruleIds, ruleIds are also clickable.
It also shows a bit of context where the error happened, Making easier to understand the nature of the error
If you use iTerm2 or Guake* the link for the file becomes clickable and will open your editor at the given line. Please make sure you have properly configured the option to open uris that matches files with your editor of choice. Sublime is a great choice!, but this should work as well with other editors that understand the pattern used by sublime
* Note: Until Guake v0.7.3 is released, it may be necessary to compile master from source.
npm i --save-dev eslint-formatter-friendly
Install eslint
and eslint-formatter-friendly
.
npm i -D eslint eslint-formatter-friendly
Add a script to your package json like:
{
"scripts": {
"eslint": "eslint --format friendly file1 file2 dir1/ dir2/",
}
}
Note: In windows you might not need the quotes around the path to the module.
{
"scripts": {
"eslint": "eslint --format friendly file1 file2 dir1/ dir2/",
}
}
see issue #17
Create a external tool to run eslint using this module as your formatter like this
npm
run eslint
$ProjectFileDir$
Use an output filter like:
$FILE_PATH$.*:$LINE$.*:$COLUMN$
When launching the tool now the files will be also clickable, see:
In the command line
# just make sure you pass the path to the module to the format option of eslint
eslint.js --format './friendly/index.js' index.js test/ -c './eslint.json'
Or as a module
var eslint = require('eslint');
var opts = readJson('./path/to/options');
var engine = new eslint.CLIEngine( opts );
var report = engine.executeOnFiles( ['file1.js', 'file2.js'/*, ...*/] );
var results = report.results || [];
var formatter = require('eslint-formatter-friendly');
var output = formatter(results);
// this will print the report if any...
console.log(output);
It works with gulp
and gulp-eslint
var friendlyFormatter = require("eslint-formatter-friendly");
// Your js task
gulp.task("javascript", function() {
return gulp.src(["src/js/**/*.js"])
// Your eslint pipe
.pipe(eslint(".eslintrc"))
.pipe(eslint.format(friendlyFormatter))
// Continue your other tasks
.pipe(concat("app.js"))
.pipe(gulp.dest("dist/js"))
});
It should work well in with eslint-grunt or grunt-eslint
grunt.initConfig({
// when using eslint-grunt:
eslint: {
options: {
formatter: './friendly'
}),
target1: {
//..
}
},
// when using grunt-eslint:
eslint: {
options: {
format: './friendly'
}),
target2: {
//..
}
}
});
Eslint does not support passing parameters to formatters from the cli yet.So in order
to pass parameters to the formatter we will have to rely on environment variables
Only shows the errors
/warnigs
that match the given ruleId
filter. This option will only filter the reported rules the error and warning counts will be the same as when all rules are reported same as the exit code.
EFF_FILTER=global-require EFF_BY_ISSUE=true eslint -f friendly client/**/*.js server/**/*.js
Normally the reporter will group issues by file, which is handy for normal development. But there are some cases where you might want to fix all the errors of a same kind all at once. For those cases this flag can be used to make the reporter group the issues by ruleId.
EFF_BY_ISSUE=true eslint -f friendly client/**/*.js server/**/*.js
By default the reporter will include a block of code to provide context, but we can omit this if we're only interested in the line where the issue is happening. If this is true it will hide the blocks of code.
EFF_NO_SOURCE=true eslint -f friendly client/**/*.js server/**/*.js
EFF_NO_GRAY
Disable the gray color output
We use the gray color to show some info about the context where the error/warning happens. If for some reason you want to disable the gray color, in cases like this one , you can do it using an environment variable.
export EFF_NO_GRAY=true
And the gray color won't be used.
EFF_ABSOLUTE_PATHS
Make the paths of the files in the reporter be absolute instead of relative as it is by default in the received results.
Some terminals work better with relative paths (like iTerm2
with fish
) and other dislike it like Guake
. So starting in version v.1.1.0 the paths will be relative by deafult. If you need the absolute please export the following variable
export EFF_ABSOLUTE_PATHS=true
EFF_EDITOR_SCHEME
If this parameter is set, a url will be output below the filename.
Some terminals only support clicking on urls, and editors can be configured to respond to custom url schemes.
export EFF_EDITOR_SCHEME=editor://open?file={file}&line={line}&column={column}
MIT
FAQs
simple formatter/reporter for eslint that's friendly with Sublime Text and iterm2 'click to open file' functionality
The npm package eslint-formatter-friendly receives a total of 142,542 weekly downloads. As such, eslint-formatter-friendly popularity was classified as popular.
We found that eslint-formatter-friendly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.