All Projects β†’ webpack-contrib β†’ Eslint Loader

webpack-contrib / Eslint Loader

Licence: mit
[DEPRECATED] A ESlint loader for webpack

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Eslint Loader

Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (-68.6%)
Mutual labels:  webpack, loader
Babel Loader
πŸ“¦ Babel loader for webpack
Stars: ✭ 4,570 (+328.3%)
Mutual labels:  webpack, loader
Sass Loader
Compiles Sass to CSS
Stars: ✭ 3,718 (+248.45%)
Mutual labels:  webpack, loader
Awesome Typescript Loader
Awesome TypeScript loader for webpack
Stars: ✭ 2,357 (+120.9%)
Mutual labels:  webpack, loader
Node Native Ext Loader
Loader for Node native extensions
Stars: ✭ 51 (-95.22%)
Mutual labels:  webpack, loader
Style Resources Loader
CSS processor resources loader for webpack
Stars: ✭ 214 (-79.94%)
Mutual labels:  webpack, loader
Phaser Ce Npm Webpack Typescript Starter Project
Project to get you started with your Phaser-CE (using the npm module) game using Typescript and Webpack for building! No hassle asset management, Google Web Font loader, live server, development vs distribution build pipeline, Electron packaging for desktop builds, and more...
Stars: ✭ 414 (-61.2%)
Mutual labels:  webpack, loader
React Hot Loader Loader
A Webpack Loader that automatically inserts react-hot-loader to your App πŸ‘¨β€πŸ”¬
Stars: ✭ 176 (-83.51%)
Mutual labels:  webpack, loader
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (-43.39%)
Mutual labels:  webpack, loader
React Imported Component
βœ‚οΈπŸ“¦Bundler-independent solution for SSR-friendly code-splitting
Stars: ✭ 525 (-50.8%)
Mutual labels:  webpack, loader
React Redux Webpack Starter
Learning react
Stars: ✭ 189 (-82.29%)
Mutual labels:  webpack, loader
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (-11.43%)
Mutual labels:  webpack, loader
Webpack2 Lessons
πŸ“–γ€Šwebpack2 εŒ…ζ•™δΈεŒ…δΌšγ€‹
Stars: ✭ 187 (-82.47%)
Mutual labels:  webpack, loader
Vue I18n Loader
🌐 vue-i18n loader for custom blocks
Stars: ✭ 229 (-78.54%)
Mutual labels:  webpack, loader
Purs Loader
PureScript loader for webpack
Stars: ✭ 182 (-82.94%)
Mutual labels:  webpack, loader
Css Loader
CSS Loader
Stars: ✭ 4,067 (+281.16%)
Mutual labels:  webpack, loader
Webpack Config Handbook
Minimum Webpack config handbook & examples
Stars: ✭ 165 (-84.54%)
Mutual labels:  webpack, loader
Pug As Jsx Loader
Stars: ✭ 168 (-84.25%)
Mutual labels:  webpack, loader
Angular Hmr
πŸ”₯ Angular Hot Module Replacement for Hot Module Reloading
Stars: ✭ 490 (-54.08%)
Mutual labels:  webpack, loader
Stylefmt Loader
Webpack-loader. Fixes stylelint issues automatically while bundling with Webpack.
Stars: ✭ 24 (-97.75%)
Mutual labels:  webpack, loader

npm node deps tests coverage chat size

eslint-loader

A ESlint loader for webpack

⚠️ DEPRECATED

eslint-loader has been deprecated. Please use eslint-webpack-plugin.

Install

npm install eslint-loader --save-dev

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

npm install eslint --save-dev

Usage

In your webpack configuration:

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          // eslint options (if necessary)
        },
      },
    ],
  },
  // ...
};

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:

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: ['babel-loader', 'eslint-loader'],
      },
    ],
  },
  // ...
};

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

module.exports = {
  // ...
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
      },
    ],
  },
  // ...
};

Options

You can pass eslint options using standard webpack loader options.

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 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 can either be a boolean value or the cache directory path(ex: './.eslint-loader-cache').

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

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          cache: true,
        },
      },
    ],
  },
};

eslintPath

  • 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.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          eslintPath: path.join(__dirname, 'reusable-eslint'),
        },
      },
    ],
  },
};

fix

  • Type: Boolean
  • Default: false

This option will enable ESLint autofix feature.

Be careful: this option will change source files.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          fix: true,
        },
      },
    ],
  },
};

formatter

  • Type: String|Function
  • Default: stylish

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.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        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';
          },
        },
      },
    ],
  },
};

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:

emitError

  • Type: Boolean
  • Default: false

Will always return errors, if this option is set to true.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          emitError: true,
        },
      },
    ],
  },
};

emitWarning

  • Type: Boolean
  • Default: false

Will always return warnings, if option is set to true. If you're using hot module replacement, you may wish to enable this in development, or else updates will be skipped when there's an eslint error.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          emitWarning: true,
        },
      },
    ],
  },
};

failOnError

  • Type: Boolean
  • Default: false

Will cause the module build to fail if there are any errors, if option is set to true.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          failOnError: true,
        },
      },
    ],
  },
};

failOnWarning

  • Type: Boolean
  • Default: false

Will cause the module build to fail if there are any warnings, if option is set to true.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          failOnWarning: true,
        },
      },
    ],
  },
};

quiet

  • Type: Boolean
  • Default: false

Will process and report errors only and ignore warnings, if this option is set to true.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          quiet: true,
        },
      },
    ],
  },
};

outputReport

  • 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.

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.

module.exports = {
  entry: '...',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          outputReport: {
            filePath: 'checkstyle.xml',
            formatter: 'checkstyle',
          },
        },
      },
    ],
  },
};

Gotchas

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.

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. See #129.

Changelog

Changelog

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].