Add rule to enforce one provide per file
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('./util');
|
||||
|
||||
exports.rule = {
|
||||
meta: {
|
||||
docs: {
|
||||
description: 'disallow multiple goog.provide() calls'
|
||||
}
|
||||
},
|
||||
|
||||
create: function(context) {
|
||||
let hasProvide = false;
|
||||
|
||||
return {
|
||||
ExpressionStatement: function(statement) {
|
||||
if (util.isProvideStatement(statement)) {
|
||||
if (hasProvide) {
|
||||
const name = statement.expression.arguments[0].value;
|
||||
context.report(statement, `Extra goog.provide('${name}')`);
|
||||
} else {
|
||||
hasProvide = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user