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 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | var assert = require('assert');
|
41 |
|
42 | module.exports = function() {};
|
43 |
|
44 | module.exports.prototype = {
|
45 |
|
46 | configure: function(options) {
|
47 | if (typeof options !== 'object') {
|
48 | assert(
|
49 | options === true,
|
50 | this.getOptionName() + ' option requires either a true value or an object'
|
51 | );
|
52 |
|
53 | var _options = {files: true};
|
54 | return this.configure(_options);
|
55 | }
|
56 |
|
57 | this._checkFiles = (options.files === true);
|
58 | },
|
59 |
|
60 | getOptionName: function() {
|
61 | return 'requireUseStrict';
|
62 | },
|
63 |
|
64 | check: function(file, errors) {
|
65 | var program = file.getProgram();
|
66 | var directive = program.directives[0];
|
67 |
|
68 | if (directive) {
|
69 | return;
|
70 | }
|
71 |
|
72 | errors.add(
|
73 | '`"use strict";` is required at the top of each file',
|
74 | program
|
75 | );
|
76 | }
|
77 | };
|