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-phpcs

v3.1.0

Published

PHP Code Sniffer plugin for Gulp

Downloads

3,922

Readme

gulp-phpcs NPM version Build Status

Gulp plugin for running PHP Code Sniffer.

Install

  1. Choose correct version of gulp-phpcs. One should use [email protected] for PHPCS 2.x and [email protected] with PHPCS 3.x.

  2. Install the plugin with the following command:

    npm install gulp-phpcs --save-dev
  3. Install PHP Code Sniffer

Usage

var gulp = require('gulp');
var phpcs = require('gulp-phpcs');

gulp.task('default', function () {
    return gulp.src(['src/**/*.php', '!src/vendor/**/*.*'])
        // Validate files using PHP Code Sniffer
        .pipe(phpcs({
            bin: 'src/vendor/bin/phpcs',
            standard: 'PSR2',
            warningSeverity: 0
        }))
        // Log all problems that was found
        .pipe(phpcs.reporter('log'));
});

API

phpcs(options)

options.bin

Type: String

Default: 'phpcs'

PHP Code Sniffer executable.

options.severity

Type: Integer

The minimum severity required to display an error or warning.

This option is equivalent to Code Sniffer --severity=<severity> option.

options.warningSeverity

Type: Integer

The minimum severity required to display an error or warning.

This option is equivalent to Code Sniffer --warning-severity=<severity> option.

options.errorSeverity

Type: Integer

The minimum severity required to display an error or warning.

This option is equivalent to Code Sniffer --error-severity=<severity> option.

options.standard

Type: String

The name or path of the coding standard to use. One can use this option to specify custom phpcs.xml file.

This option is equivalent to Code Sniffer --standard="<standard>" option.

options.encoding

Type: String

The encoding of the files being checked.

This option is equivalent to Code Sniffer --encoding="<encoding>" option.

options.report

Type: String

The report type to generate.

This option is equivalent to Code Sniffer --report="<report>" option.

options.showSniffCode

Type: Boolean

Display sniff codes in the report.

This option is equivalent to Code Sniffer -s option.

options.sniffs

Type: Array

Filter for executed Sniffs

This option is equivalent to Code Sniffer --sniffs option.

options.exclude

Type: Array

Exclude some sniffs from ruleset.

This option is equivalent to Code Sniffer --exclude option.

options.ignore

Type: Array

Ignore a list of paths

This option is equivalent to Code Sniffer --ignore option.

options.cwd

Type: String

Set an explicit current working directory from which the phpcs command should run.

options.colors

Type: Boolean

Pass colorized output of Code Sniffer to reporters.

This option is equivalent to Code Sniffer --colors option.

Warning: This options is only compatible with 2.x branch of Code Sniffer.

phpcs.reporter(name[, options])

Loads one of the reporters that shipped with the plugin (see below).

name

Type: String

The name of the reporter that should be loaded.

options

Type: Object

Options for the reporter if needed.

Reporters

The plugin only pass files through PHP Code Sniffer. To process the results of the check one should use a reporter. Reporters are plugins too, so one can pipe a files stream to them. Several repotrers can be used on a stream, just like any other plugins.

These reporters are shipped with the plugin:

  1. Fail reporter - fails if a problem was found. Use phpcs.reporter('fail', {failOnFirst: true}) to load it. failOnFirst option is used to choose when the reporter should fail on the first errored file or at the end of the file stream. This option can be omitted (true is used by default).

  2. Log reporter - outputs all problems to the console. Use phpcs.reporter('log') to load it.

  3. File reporter - outputs all problems to a file. Use phpcs.reporter('file', { path: "path/to/report.txt" }) to load it.

License

MIT © Dmitriy Simushev