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

eslint-loader

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-loader - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

12

CHANGELOG.md

@@ -0,4 +1,14 @@

# 0.5.0 - 2015-02-11
- Changed: upgrade to eslint 0.16.x
- Changed: `emitErrors` is now `emitError`
- Changed: loader now use `webpack.emitError` or `webpack.emitWarning` automatically (according to eslint configuration).
You can still override by using `emitError` or `emitWarning` options to override this behavior
- Added: `emitWarning` can force eslint to report warning instead of the default behavior (see above)
- Added: `quiet` option to hide warnings
# 0.4.0 - 2015-02-23
- Changed: upgrate to eslint 0.15.x
- Changed: upgrade to eslint 0.15.x
- Changed: more readable default reporter

@@ -5,0 +15,0 @@ - Added: `reporter` options allow to define a custom reporter function

69

index.js
"use strict";
var eslint = require("eslint").linter
var Config = require("eslint/lib/config");
var eslint = require("eslint")
var stylish = require("eslint/lib/formatters/stylish")
// eslint empty filename
var TEXT = "<text>"
/**
* linter
*
* @param {String|Buffer} input
* @param {Object} config
* @param {Object} webpack
* @param {String|Buffer} input JavaScript string
* @param {Object} config eslint configuration
* @param {Object} webpack webpack instance
* @returns {void}
*/
function lint(input, config, webpack) {
var res = eslint.verify(input, config)
if (res.length) {
var res = config.executeOnText(input)
// executeOnText ensure we will have res.results[0] only
// quiet filter done now
// eslint allow rules to be specified in the input between comments
// so we can found warnings defined in the input itself
if (res.warningCount && webpack.options.eslint.quiet) {
res.warningCount = 0
res.results[0].warningCount = 0
res.results[0].messages = res.results[0].messages.filter(function(message) {
return message.severity !== 1
})
}
if (res.errorCount || res.warningCount) {
var reporter = webpack.options.eslint.reporter || function(results) {
// in order to use eslint formatters
// we need to reproduce the object passed to them
var msgs = stylish([{
filePath: "",
messages: results
}]).split("\n")
// drop the line that should contains filepath we do not have
msgs.splice(0, 1)
return stylish(results).split("\n").filter(function(line) {
// drop the line that should contains filepath we do not have
return !line.match(TEXT)
}).join("\n")
}
var messages = reporter(res.results)
return msgs.join("\n")
// default behavior: emit error only if we have errors
var emitter = res.errorCount ? webpack.emitError : webpack.emitWarning
// force emitError or emitWarning if user want this
if (webpack.options.eslint.emitError) {
emitter = webpack.emitError
}
var messages = reporter(res)
var emitter = webpack.options.eslint.emitErrors ? webpack.emitError : webpack.emitWarning
else if (webpack.options.eslint.emitWarning) {
emitter = webpack.emitWarning
}

@@ -45,14 +64,16 @@ if (emitter) {

*
* @param {String|Buffer} input
* @return {String|Buffer}
* @param {String|Buffer} input JavaScript string
* @returns {String|Buffer} original input
*/
module.exports = function(input) {
this.options.eslint = this.options.eslint || {}
this.cacheable()
// sync
var config = new Config(this.options.eslint).getConfig()
// sync loader
var config = new eslint.CLIEngine(this.options.eslint)
lint(input, config, this)
// this loader do nothing
return input
}
{
"name": "eslint-loader",
"version": "0.4.0",
"version": "0.5.0",
"description": "eslint loader (for webpack)",

@@ -27,13 +27,9 @@ "keywords": [

"peerDependencies": {
"eslint": "^0.15.0"
"eslint": "^0.16.0"
},
"dependencies": {
"loader-utils": "^0.2.5",
"object-assign": "^2.0.0",
"rcloader": "^0.1.2",
"strip-json-comments": "^1.0.2"
"object-assign": "^2.0.0"
},
"devDependencies": {
"eslint": "^0.15.0",
"jscs": "^1.8.1",
"eslint": "^0.16.0",
"tape": "^3.0.3",

@@ -43,6 +39,5 @@ "webpack": "^1.4.13"

"scripts": {
"jscs": "jscs *.js **/*.js",
"eslint": "eslint *.js **/*.js",
"test": "npm run jscs && npm run eslint && tape test/*.js"
"lint": "eslint .",
"test": "npm run lint && tape test/*.js"
}
}

@@ -41,8 +41,15 @@ # eslint-loader [![Build Status](http://img.shields.io/travis/MoOx/eslint-loader.svg)](https://travis-ci.org/MoOx/eslint-loader)

Loader accepts a function that will have one argument: an array of eslint messages (object)
Loader accepts a function that will have one argument: an array of eslint messages (object).
The function must return the output as a string.
#### `emitErrors` (default: `false`)
#### Errors and Warning
Loader will returns error instead of warning if this option is set to true
**By default the loader will auto adjust error reporting depending
on eslint errors/warnings counts.**
You can still force this behavior
##### `emitError` (default: `false`)
Loader will always returns errors if this option is set to `true`.
```js

@@ -60,4 +67,24 @@ module.exports = {

##### `emitWarning` (default: `false`)
Loader will always returns warning if option is set to `true`.
#### `quiet` (default: `false`)
Loader will process and report errors only and ignore warnings if this option is set to true
```js
module.exports = {
entry: "...",
module: {
// ...
}
eslint: {
quiet: true
}
}
```
## [Changelog](CHANGELOG.md)
## [License](LICENSE)
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