How to use the eslint.linter.defineRule function in eslint

To help you get started, we’ve selected a few eslint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yyx990803 / semi / lib / index.js View on Github external
var linter = require('eslint').linter
var Emitter = require('events').EventEmitter
var api = module.exports = new Emitter
var offsets
var lines

// ES6 feature options
var ecmaFeatures = require('./features')

// define our custom rule
linter.defineRule('autosemi', require('./rule'))

/**
 * Process a file buffer with given options.
 *
 * @param {String} file - file to process
 * @param {String} action - "add" or "remove"
 * @param {Object} options
 * @return {String}
 */

function process (file, action, options) {
  // reset state
  lines = file.split('\n')
  offsets = {}
  // lint
  var ops = linter.verify(file, {
github google / eslint-closure / packages / eslint-plugin-googlejs / lib / config-tester.js View on Github external
ConfigTester.prototype.defineRule = function(name, rule) {
  linter.defineRule(name, rule);
};
github ecomfe / fecs / lib / js / rules / index.js View on Github external
fs.readdirSync(dir).forEach(function (file) {
        if (file === cur) {
            return;
        }

        var match = file.match(reg);
        if (match) {
            var key = 'fecs-' + match[1].replace(/[A-Z]/g, function (a) {
                return '-' + a.toLowerCase();
            });

            eslint.defineRule(key, path.join(dir, file));
        }
    });
};