Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack-contrib/eslint-loader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.2
Choose a base ref
...
head repository: webpack-contrib/eslint-loader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.3
Choose a head ref
  • 10 commits
  • 6 files changed
  • 1 contributor

Commits on Oct 9, 2019

  1. docs: formatting

    ricardogobbosouza authored Oct 9, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2dd8b43 View commit details

Commits on Dec 4, 2019

  1. docs: formatting

    ricardogobbosouza committed Dec 4, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2346ff8 View commit details
  2. chore: update deps

    ricardogobbosouza committed Dec 4, 2019
    Copy the full SHA
    356c8e2 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    dab6d65 View commit details
  4. docs: update

    ricardogobbosouza authored Dec 4, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f06c9e8 View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7793ccf View commit details

Commits on Dec 6, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6bb1fa6 View commit details
  2. Copy the full SHA
    c0a9d0c View commit details
  3. Copy the full SHA
    ee68817 View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    23695fc View commit details
Showing with 2,429 additions and 1,937 deletions.
  1. +8 −0 CHANGELOG.md
  2. +43 −65 README.md
  3. +1,291 −916 package-lock.json
  4. +19 −19 package.json
  5. +16 −4 src/Linter.js
  6. +1,052 −933 yarn.lock
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [3.0.3](https://github.com/webpack-contrib/eslint-loader/compare/v3.0.2...v3.0.3) (2019-12-06)


### Bug Fixes

* check result object ([#311](https://github.com/webpack-contrib/eslint-loader/issues/311)) ([6bb1fa6](https://github.com/webpack-contrib/eslint-loader/commit/6bb1fa68d043f00de63cda4d9babd3a2c9a50d58))
* support webpack 5 ([#312](https://github.com/webpack-contrib/eslint-loader/issues/312)) ([c0a9d0c](https://github.com/webpack-contrib/eslint-loader/commit/c0a9d0c118155c56c41dc344460f333a9e969eaf))

### [3.0.2](https://github.com/webpack-contrib/eslint-loader/compare/v3.0.1...v3.0.2) (2019-09-27)


108 changes: 43 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,23 +13,23 @@

# eslint-loader

> ESlint loader for webpack
> A ESlint loader for webpack
## Install

```bash
npm install eslint-loader --save-dev
```

**NOTE**: You also need to install `eslint` from npm, if you haven't already:
**Note**: You also need to install `eslint` from npm, if you haven't already:

```bash
npm install eslint --save-dev
```

## Usage

In your webpack configuration
In your webpack configuration:

```js
module.exports = {
@@ -50,8 +50,7 @@ module.exports = {
};
```

When using with transpiling loaders (like `babel-loader`), make sure they are in correct order
(bottom to top). Otherwise files will be checked after being processed by `babel-loader`
When using with transpiling loaders (like `babel-loader`), make sure they are in correct order (bottom to top). Otherwise files will be checked after being processed by `babel-loader`:

```js
module.exports = {
@@ -69,8 +68,7 @@ module.exports = {
};
```

To be safe, you can use `enforce: 'pre'` section to check source files, not modified
by other loaders (like `babel-loader`)
To be safe, you can use `enforce: 'pre'` section to check source files, not modified by other loaders (like `babel-loader`):

```js
module.exports = {
@@ -96,25 +94,20 @@ module.exports = {

## Options

You can pass [eslint options](http://eslint.org/docs/developer-guide/nodejs-api#cliengine)
using standard webpack [loader options](https://webpack.js.org/configuration/module/#useentry).
You can pass [eslint options](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) using standard webpack [loader options](https://webpack.js.org/configuration/module/#useentry).

Note that the config option you provide will be passed to the `CLIEngine`.
This is a different set of options than what you'd specify in `package.json` or `.eslintrc`.
See the [eslint docs](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) for more detail.
Note that the config option you provide will be passed to the `CLIEngine`. This is a different set of options than what you'd specify in `package.json` or `.eslintrc`. See the [eslint docs](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) for more detail.

### `cache`

- Type: `Boolean|String`
- Default: `false`

This option will enable caching of the linting results into a file.
This is particularly useful in reducing linting time when doing a full build.
This option will enable caching of the linting results into a file. This is particularly useful in reducing linting time when doing a full build.

This can either be a `boolean` value or the cache directory path(ex: `'./.eslint-loader-cache'`).

If `cache: true` is used, the cache file is written to the `./node_modules/.cache` directory.
This is the recommended usage.
If `cache: true` is used, the cache is written to the `./node_modules/.cache/eslint-loader` directory. This is the recommended usage.

```js
module.exports = {
@@ -139,9 +132,7 @@ module.exports = {
- Type: `String`
- Default: `eslint`

Path to `eslint` instance that will be used for linting.
If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option.
now you dont have to install `eslint`.
Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. Now you dont have to install `eslint`.

```js
module.exports = {
@@ -161,14 +152,14 @@ module.exports = {
};
```

### `formatter`
### `fix`

- Type: `String|Function`
- Default: `stylish`
- Type: `Boolean`
- Default: `false`

This option accepts a function that will have one argument: an array of eslint messages (object).
The function must return the output as a string.
You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
This option will enable [ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).

**Be careful: this option will change source files.**

```js
module.exports = {
@@ -180,39 +171,20 @@ module.exports = {
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
// several examples !

// default value
formatter: 'stylish',

// community formatter
formatter: require('eslint-friendly-formatter'),

// custom formatter
formatter: function(results) {
// `results` format is available here
// http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles()

// you should return a string
// DO NOT USE console.*() directly !
return 'OUTPUT';
},
fix: true,
},
},
],
},
};
```

### `fix`
### `formatter`

- Type: `Boolean`
- Default: `false`
- Type: `String|Function`
- Default: `stylish`

This option will enable
[ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).

**Be careful: this option will change source files.**
This option accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).

```js
module.exports = {
@@ -224,7 +196,23 @@ module.exports = {
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
fix: true,
// several examples !

// default value
formatter: 'stylish',

// community formatter
formatter: require('eslint-friendly-formatter'),

// custom formatter
formatter: function(results) {
// `results` format is available here
// http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles()

// you should return a string
// DO NOT USE console.*() directly !
return 'OUTPUT';
},
},
},
],
@@ -234,9 +222,7 @@ module.exports = {

### Errors and Warning

**By default the loader will auto adjust error reporting depending
on eslint errors/warnings counts.**
You can still force this behavior by using `emitError` **or** `emitWarning` options:
**By default the loader will auto adjust error reporting depending on eslint errors/warnings counts.** You can still force this behavior by using `emitError` **or** `emitWarning` options:

#### `emitError`

@@ -368,11 +354,9 @@ module.exports = {
- Type: `Boolean|Object`
- Default: `false`

Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI
Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI.

The `filePath` is an absolute path or relative to the webpack config: `output.path`
You can pass in a different `formatter` for the output file,
if none is passed in the default/configured formatter will be used
The `filePath` is an absolute path or relative to the webpack config: `output.path`. You can pass in a different `formatter` for the output file, if none is passed in the default/configured formatter will be used.

```js
module.exports = {
@@ -399,17 +383,11 @@ module.exports = {

### NoEmitOnErrorsPlugin

`NoEmitOnErrorsPlugin` is now automatically enabled in webpack 4, when mode is either unset,
or set to production. So even ESLint warnings will fail the build.
No matter what error settings are used for `eslint-loader`, except if `emitWarning` enabled.
`NoEmitOnErrorsPlugin` is now automatically enabled in webpack 4, when mode is either unset, or set to production. So even ESLint warnings will fail the build. No matter what error settings are used for `eslint-loader`, except if `emitWarning` enabled.

### Defining `configFile` or using `eslint -c path/.eslintrc`

Bear in mind that when you define `configFile`, `eslint` doesn't automatically look for
`.eslintrc` files in the directory of the file to be linted.
More information is available in official eslint documentation in section
[_Using Configuration Files_](http://eslint.org/docs/user-guide/configuring#using-configuration-files).
See [#129](https://github.com/webpack-contrib/eslint-loader/issues/129).
Bear in mind that when you define `configFile`, `eslint` doesn't automatically look for `.eslintrc` files in the directory of the file to be linted. More information is available in official eslint documentation in section [_Using Configuration Files_](http://eslint.org/docs/user-guide/configuring#using-configuration-files). See [#129](https://github.com/webpack-contrib/eslint-loader/issues/129).

## Changelog

2,207 changes: 1,291 additions & 916 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eslint-loader",
"version": "3.0.2",
"description": "ESlint loader for webpack",
"version": "3.0.3",
"description": "A ESlint loader for webpack",
"license": "MIT",
"repository": "webpack-contrib/eslint-loader",
"author": "Maxime Thirouin",
@@ -35,43 +35,43 @@
],
"peerDependencies": {
"eslint": "^5.0.0 || ^6.0.0",
"webpack": "^4.0.0"
"webpack": "^4.0.0 || ^5.0.0"
},
"dependencies": {
"fs-extra": "^8.1.0",
"loader-fs-cache": "^1.0.2",
"loader-utils": "^1.2.3",
"object-hash": "^1.3.1",
"schema-utils": "^2.2.0"
"object-hash": "^2.0.1",
"schema-utils": "^2.6.1"
},
"devDependencies": {
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.6.2",
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@webpack-contrib/defaults": "^5.0.2",
"@webpack-contrib/defaults": "^5.1.1",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"chokidar": "^3.1.1",
"chokidar": "^3.3.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"cross-env": "^6.0.0",
"cross-env": "^6.0.3",
"del": "^5.1.0",
"del-cli": "^3.0.0",
"eslint": "^6.4.0",
"eslint-config-prettier": "^6.3.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-plugin-import": "^2.18.2",
"husky": "^3.0.5",
"husky": "^3.1.0",
"jest": "^24.9.0",
"jest-junit": "^8.0.0",
"lint-staged": "^9.2.3",
"jest-junit": "^10.0.0",
"lint-staged": "^9.5.0",
"mkdirp": "^0.5.1",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"standard-version": "^7.0.0",
"webpack": "^4.41.0"
"prettier": "^1.19.1",
"standard-version": "^7.0.1",
"webpack": "^4.41.2"
},
"keywords": [
"eslint",
20 changes: 16 additions & 4 deletions src/Linter.js
Original file line number Diff line number Diff line change
@@ -83,7 +83,10 @@ export default class Linter {

static skipIgnoredFileWarning(res) {
return (
res &&
res.warningCount === 1 &&
res.results &&
res.results[0] &&
res.results[0].messages[0] &&
res.results[0].messages[0].message &&
res.results[0].messages[0].message.indexOf('ignore') > 1
@@ -96,7 +99,13 @@ export default class Linter {
// 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 (this.options.quiet && res.warningCount) {
if (
this.options.quiet &&
res &&
res.warningCount &&
res.results &&
res.results[0]
) {
res.warningCount = 0;
res.results[0].warningCount = 0;
res.results[0].messages = res.results[0].messages.filter(
@@ -109,9 +118,12 @@ export default class Linter {

autoFix(res) {
if (
res.results[0].output !== res.src ||
res.results[0].fixableErrorCount > 0 ||
res.results[0].fixableWarningCount > 0
res &&
res.results &&
res.results[0] &&
(res.results[0].output !== res.src ||
res.results[0].fixableErrorCount > 0 ||
res.results[0].fixableWarningCount > 0)
) {
this.CLIEngine.outputFixes(res);
}
1,985 changes: 1,052 additions & 933 deletions yarn.lock

Large diffs are not rendered by default.