Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/readjs/node_modules/gulp-csslint/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/readjs/node_modules/gulp-csslint/index.js
'use strict';

var gutil = require('gulp-util');
var through = require('through2');
var csslint = require('csslint').CSSLint;
var RcLoader = require('rcloader');

function validateFormatter(formatter) {
  if (typeof formatter !== 'object' || !formatter.id || !formatter.startFormat || !formatter.endFormat || !formatter.endFormat || !formatter.formatResults) {
    throw new Error('Invalid formatter: formatters need to be objects, and contain "id", "name", "startFormat", "endFormat" and "formatResults"');
  }
}

var cssLintPlugin = function(options) {
  options = options || {};
  var rcLoader = new RcLoader('.csslintrc', options, { loader: 'async' });
  return through.obj(function(file, enc, cb) {
    if (file.isNull()) return cb(null, file); // pass along
    if (file.isStream()) return cb(new gutil.PluginError('gulp-csslint: Streaming not supported'), file);

    var ruleset = {};
    // Build a list of all available rules
    csslint.getRules().forEach(function(rule) {
      ruleset[rule.id] = 1;
    });

    var content = file.contents.toString(enc);

    if (!content) return cb(null, file); // pass along

    rcLoader.for(file.path, function(err, opts) {
      if (err) return cb(err);

      for (var rule in opts) {
        if (!opts[rule]) {
          // Remove rules that are turned off
          delete ruleset[rule];
        }
        else {
          ruleset[rule] = opts[rule];
        }
      }

      var report = csslint.verify(content, ruleset);

      // send status down-stream
      file.csslint = { report: report, success: !report.messages.length };

      cb(null, file);
    });
  });
};

cssLintPlugin.formatter = function(customFormatter, options) {
  var formatter = csslint.getFormatter('text');
  var builtInFormatter = true;
  var output;

  options = options || {};

  var logger = options.logger || process.stdout.write.bind(process.stdout);
  if (customFormatter) {
    if (typeof customFormatter === 'function') {
      formatter = customFormatter;
      builtInFormatter = false;
    }
    else if (typeof customFormatter === 'string') {
      if (customFormatter === 'fail') {
        return cssLintPlugin.failFormatter();
      }

      formatter = csslint.getFormatter(customFormatter);

      if (typeof formatter === 'undefined') {
        throw new Error('Invalid reporter: ' + customFormatter);
      }
    }
    else if (typeof customFormatter === 'object') {
      validateFormatter(customFormatter);
      formatter = customFormatter;
    }
    else {
      throw new Error('Invalid custom formatter passed, please pass `null` or `undefined` if you want to pass options while using default formatter.');
    }
  }

  if (builtInFormatter) {
    output = [formatter.startFormat()];
  }

  return through.obj(
    function(file, enc, cb) {
      // Only report if CSSLint was ran and errors were found
      if (file.csslint && !file.csslint.success) {
        if (builtInFormatter) {
          output.push(formatter.formatResults(file.csslint.report, file.path, options));
        }
        else {
          formatter(file.csslint.report, file.path, options);
        }
      }

      return cb(null, file);
    },
    function(cb) {
      if (builtInFormatter) {
        output.push(formatter.endFormat());

        output
          .filter(function(str) {
            return str;
          })
          .forEach(logger);
      }

      return cb();
    }
  ).resume(); // Force flow-mode https://nodejs.org/docs/latest/api/stream.html#stream_event_end
};

cssLintPlugin.addRule = function(rule) {
  if (typeof rule !== 'object') {
    throw new Error('Invalid rule: rules need to be objects.');
  }
  csslint.addRule(rule);
};

cssLintPlugin.addFormatter = function(formatter) {
  formatter = typeof formatter === 'string' ? require(formatter) : formatter;
  validateFormatter(formatter);

  csslint.addFormatter(formatter);
};

cssLintPlugin.failFormatter = function() {
  return through.obj(function(file, enc, cb) {
    // Nothing to report or no errors
    if (!file.csslint || file.csslint.success) {
      return cb(null, file);
    }

    return cb(new gutil.PluginError('gulp-csslint', 'CSSLint failed for ' + file.relative), file);
  });
};

module.exports = cssLintPlugin;

Youez - 2016 - github.com/yon3zu
LinuXploit