npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-eslint-through

v1.0.0

Published

A gulp plugin for processing files with ESLint

Downloads

9

Readme

gulp-eslint-through

A gulp plugin by through for ESLint

Installation

Use npm.

npm install gulp-eslint-through

Usage

const {src, task} = require('gulp');
const eslint = require('gulp-eslint-through');

task('default', () => {
    return src(['scripts/*.js'])
        // eslint() attaches the lint output to the "eslint" property
        // of the file object so it can be used by other modules.
        .pipe(eslint())
});

Or use the plugin API to do things like:

gulp.src(['**/*.js','!node_modules/**'])
	.pipe(eslint({
		rules: {
			'my-custom-rule': 1,
			'strict': 2
		},
		globals: [
			'jQuery',
			'$'
		],
		envs: [
			'browser'
		]
	}))

API

eslint()

No explicit configuration. A .eslintrc file may be resolved relative to each linted file.

eslint(options)

See ESlint CLIEngine options.

options.rules

Type: Object

Set configuration of rules.

{
	"rules":{
		"camelcase": 1,
		"comma-dangle": 2,
		"quotes": 0
	}
}

options.globals

Type: Array

Specify global variables to declare.

{
	"globals":[
		"jQuery",
		"$"
	]
}

options.fix

Type: Boolean

This option instructs ESLint to try to fix as many issues as possible. The fixes are applied to the gulp stream. The fixed content can be saved to file using gulp.dest (See example/fix.js). Rules that are fixable can be found in ESLint's rules list.

When fixes are applied, a "fixed" property is set to true on the fixed file's ESLint result.

options.quiet

Type: Boolean

When true, this option will filter warning messages from ESLint results. This mimics the ESLint CLI quiet option.

Type: function (message, index, list) { return Boolean(); }

When provided a function, it will be used to filter ESLint result messages, removing any messages that do not return a true (or truthy) value.

options.envs

Type: Array

Specify a list of environments to be applied.

options.rulePaths

Type: Array

This option allows you to specify additional directories from which to load rules files. This is useful when you have custom rules that aren't suitable for being bundled with ESLint. This option works much like the ESLint CLI's rulesdir option.

options.configFile

Type: String

Path to the ESLint rules configuration file. For more information, see the ESLint CLI config option and Using Configuration Files.

options.warnFileIgnored

Type: Boolean

When true, add a result warning when ESLint ignores a file. This can be used to file files that are needlessly being loaded by gulp.src. For example, since ESLint automatically ignores "node_modules" file paths and gulp.src does not, a gulp task may take seconds longer just reading files from the "node_modules" directory.

options.useEslintrc

Type: Boolean

When false, ESLint will not load .eslintrc files.

eslint(configFilePath)

Type: String

Shorthand for defining options.configFile.

eslint(results)

Type: function (result) {}

Call a function for each ESLint file result. No returned value is expected. If an error is thrown, it will be wrapped in a Gulp PluginError and emitted from the stream.

gulp.src(['**/*.js','!node_modules/**'])
	.pipe(eslint({
      results: (data) => {
        console.log(data)
      }
   }))

Type: function (result) { }

Call an asynchronous function for each ESLint file results. The callback must be called for the stream to finish. If a value is passed to the callback, it will be wrapped in a Gulp PluginError and emitted from the stream.

Configuration

ESLint may be configured explicity by using any of the following plugin options: config, rules, globals, or env. If the useEslintrc option is not set to false, ESLint will attempt to resolve a file by the name of .eslintrc within the same directory as the file to be linted. If not found there, parent directories will be searched until .eslintrc is found or the directory root is reached.

Ignore Files

ESLint will ignore files that do not have a .js file extension at the point of linting (some plugins may change file extensions mid-stream). This avoids unintentional linting of non-JavaScript files.

ESLint will also detect an .eslintignore file at the cwd or a parent directory. See the ESLint docs to learn how to construct this file.

Extensions

ESLint results are attached as an "eslint" property to the vinyl files that pass through a Gulp.js stream pipeline. This is available to streams that follow the initial eslint stream. The eslint.result and eslint.results methods are made available to support extensions and custom handling of ESLint results.

Gulp-Eslint Extensions: