Skip to content

Commit

Permalink
Chore: don't make Linter a subclass of EventEmitter (refs #9161)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark committed Aug 28, 2017
1 parent a8a817e commit fe69014
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/linter.js
Expand Up @@ -693,10 +693,9 @@ function parse(text, config, filePath, messages) {
* Object that is responsible for verifying JavaScript text
* @name eslint
*/
class Linter extends EventEmitter {
class Linter {

constructor() {
super();
this.messages = [];
this.currentConfig = null;
this.currentScopes = null;
Expand All @@ -709,17 +708,13 @@ class Linter extends EventEmitter {

this.rules = new Rules();
this.environments = new Environments();

// set unlimited listeners (see https://github.com/eslint/eslint/issues/524)
this.setMaxListeners(0);
}

/**
* Resets the internal state of the object.
* @returns {void}
*/
reset() {
this.removeAllListeners();
this.messages = [];
this.currentConfig = null;
this.currentScopes = null;
Expand Down Expand Up @@ -821,6 +816,10 @@ class Linter extends EventEmitter {
ast = this.sourceCode.ast;
}

const emitter = new EventEmitter();

emitter.setMaxListeners(Infinity);

// if espree failed to parse the file, there's no sense in setting up rules
if (ast) {

Expand Down Expand Up @@ -865,7 +864,7 @@ class Linter extends EventEmitter {

// add all the selectors from the rule as listeners
Object.keys(rule).forEach(selector => {
this.on(selector, timing.enabled
emitter.on(selector, timing.enabled
? timing.time(key, rule[selector])
: rule[selector]
);
Expand Down Expand Up @@ -898,9 +897,7 @@ class Linter extends EventEmitter {
// augment global scope with declared global variables
addDeclaredGlobals(ast, this.currentScopes[0], this.currentConfig, this.environments);

let eventGenerator = new NodeEventGenerator(this);

eventGenerator = new CodePathAnalyzer(eventGenerator);
const eventGenerator = new CodePathAnalyzer(new NodeEventGenerator(emitter));

/*
* Each node has a type property. Whenever a particular type of
Expand Down

0 comments on commit fe69014

Please sign in to comment.