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

pipeline-validate-js

v1.0.4

Published

Gulp pipeline to validate js files using ESLint

Downloads

50

Readme

pipeline-validate-js

GitHub release npm Jenkins Jenkins tests Jenkins coverage npm GitHub issues GitHub issues GitHub license

Information

| Package | Description | Version| | ------------- |:-------------:| -----:| | pipeline-validate-js| Pipeline to validate JavaScript files using ESLint | 1.0.4 |

Overview

This is a Gulp pipeline that allows a team to validate the JS files within their project for syntax and style. As part of the Keystone project for Kenzan, this pipeline is opinionated to promote best practices as favored by the organization. It defines a module that contains a validateJS method that will use ESLint to complete the task.

A fixture has been provided in test/fixtures/ of Twitter Bootstrap's source, linted according to the rules. As changes are presented to the default ruleset, the rules will be reflected in this file as well, for easy visualiztion of rule set changes.

Install

npm install pipeline-validate-js --save-dev

Usage

In addition to the default rules established within this pipeline, there is support for using personalized linting rules. If you'd like to use other rules within your project you can define a .eslintrc file. You can also pass in a file path as a parameter or pass in an object with your custom rules. This pipeline will merge your rules, favoring your rules over the default configuration.

var gulp = require('gulp');
var validatePipeline = require('pipeline-validate-js');

gulp.task('default', function() {
  return gulp
    .src('src/**/*.js')
    .pipe(validatePipeline.validateJS());
});

//specify your own custom eslintrc, that gets merged into the default config
gulp.task('default', function() {
  return gulp
    .src('src/**/*.js')
    .pipe(validatePipeline.validateJS('/some/path/.eslintrcCustom'));
});

//specify your own custom rules object, that gets merged into the default config
gulp.task('default', function() {
  return gulp
    .src('src/**/*.js')
    .pipe(validatePipeline.validateJS({
      "rules": {
        "no-console": 0
      },
      "parserOptions": {
        "ecmaVersion": 6
      }
    });
});

Options

Note: If options are invalid it will throw a reference error.

Pipeline options:

  • config -> Object that contains the configuration. It offers a 1:1 mapping with the format of an eslintrc file

    • parseOptions.ecmaVersion:__ Sets the ecmaScript version to be linted, set to '5' by default.

    Default:

    pipelineConfig = {
      parseOptions: {
        ecmaVersion: 5
      }
    }

Custom Formatter

ESLint provides the ability to output the results in a variety of formats, thus, a custom formatter can be provided via the config object.

ESLint provided formatters: https://github.com/eslint/eslint/tree/master/lib/formatters

The custom formatter options will not conflict with the default ESLint options provided, so you can provide just a formatter while retaining the default ESLint option values.

var lintConfig = {
  formatter: 'name-of-eslint-formatter'
  // OR
  // formatter: function (arrayOfResults) {
    // output something here
  // }
}

gulp.task('lint', function() {
  return gulp
    .src('src/**/*.js')
    .pipe(validatePipeline.validateJS(lintConfig));
});

Failing on Errors

By default, this pipeline will exit on a validation error. To prevent this exit on failure, provide the following option to the pipeline.

var lintConfig = {
  failOnError: false
}

gulp.task('lint', function() {
  return gulp
    .src('src/**/*.js')
    .pipe(validatePipeline.validateJS(lintConfig));
});

As with the custom formatting option, this option will not conflict with the ESLint default configuration options.

Results

This pipeline returns an object. This object receives a stream with the files to validate. You can call the validateJS method to run the validation. The method will report if any issues were found during validation. If no issues are present, it will return the stream.

LICENSE

Copyright 2015 Kenzan, LLC http://kenzan.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.