forked from ngageoint/eslint-plugin-opensphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequires-first.js
More file actions
30 lines (26 loc) · 727 Bytes
/
requires-first.js
File metadata and controls
30 lines (26 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
const util = require('./util');
exports.rule = {
meta: {
docs: {
description: 'require that all goog.require() precede other statements (except goog.provide())',
category: 'Closure Compiler'
}
},
create: function(context) {
return {
Program: function(program) {
let otherSeen = false;
program.body.forEach((statement) => {
if (util.isRequireStatement(statement)) {
if (otherSeen) {
return context.report(statement, 'Expected goog.require() to precede other statements');
}
} else if (!util.isProvideStatement(statement)) {
otherSeen = true;
}
});
}
};
}
};