Skip to content

Commit cc32972

Browse files
committed
update lint version + rules
1 parent 3852153 commit cc32972

File tree

113 files changed

+1275
-1278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1275
-1278
lines changed

babel.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module.exports = function(api) {
1+
module.exports = function (api) {
22
api.cache(true);
33

44
const presets = ["@babel/preset-env"];
55
const plugins = [];
66

77
return {
88
presets,
9-
plugins
9+
plugins,
1010
};
1111
};

jest.config.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ module.exports = {
88
projects: [
99
{
1010
displayName: "test",
11-
testEnvironment: "node"
11+
testEnvironment: "node",
1212
},
1313
{
1414
runner: "jest-runner-eslint",
1515
displayName: "lint",
1616
testMatch: ["<rootDir>/**/*.js"],
17-
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/coverage/"]
18-
}
19-
]
17+
testPathIgnorePatterns: [
18+
"<rootDir>/node_modules/",
19+
"<rootDir>/coverage/",
20+
],
21+
},
22+
],
2023
};

src/ast.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const Position = require("./ast/position");
123123
* @property {Boolean} withPositions - Should locate any node (by default false)
124124
* @property {Boolean} withSource - Should extract the node original code (by default false)
125125
*/
126-
const AST = function(withPositions, withSource) {
126+
const AST = function (withPositions, withSource) {
127127
this.withPositions = withPositions;
128128
this.withSource = withSource;
129129
};
@@ -135,7 +135,7 @@ const AST = function(withPositions, withSource) {
135135
* @return {Position}
136136
* @private
137137
*/
138-
AST.prototype.position = function(parser) {
138+
AST.prototype.position = function (parser) {
139139
return new Position(
140140
parser.lexer.yylloc.first_line,
141141
parser.lexer.yylloc.first_column,
@@ -165,23 +165,23 @@ AST.precedence = {};
165165
["!"],
166166
["instanceof"],
167167
["cast", "silent"],
168-
["**"]
168+
["**"],
169169
// TODO: [ (array)
170170
// TODO: clone, new
171-
].forEach(function(list, index) {
172-
list.forEach(function(operator) {
171+
].forEach(function (list, index) {
172+
list.forEach(function (operator) {
173173
AST.precedence[operator] = index + 1;
174174
});
175175
});
176176

177-
AST.prototype.isRightAssociative = function(operator) {
177+
AST.prototype.isRightAssociative = function (operator) {
178178
return operator === "**" || operator === "??";
179179
};
180180

181181
/**
182182
* Change parent node informations after swapping childs
183183
*/
184-
AST.prototype.swapLocations = function(target, first, last, parser) {
184+
AST.prototype.swapLocations = function (target, first, last, parser) {
185185
if (this.withPositions) {
186186
target.loc.start = first.loc.start;
187187
target.loc.end = last.loc.end;
@@ -197,7 +197,7 @@ AST.prototype.swapLocations = function(target, first, last, parser) {
197197
/**
198198
* Includes locations from first & last into the target
199199
*/
200-
AST.prototype.resolveLocations = function(target, first, last, parser) {
200+
AST.prototype.resolveLocations = function (target, first, last, parser) {
201201
if (this.withPositions) {
202202
if (target.loc.start.offset > first.loc.start.offset) {
203203
target.loc.start = first.loc.start;
@@ -217,7 +217,7 @@ AST.prototype.resolveLocations = function(target, first, last, parser) {
217217
/**
218218
* Check and fix precence, by default using right
219219
*/
220-
AST.prototype.resolvePrecedence = function(result, parser) {
220+
AST.prototype.resolvePrecedence = function (result, parser) {
221221
let buffer, lLevel, rLevel;
222222
// handling precendence
223223
if (result.kind === "call") {
@@ -349,14 +349,14 @@ AST.prototype.resolvePrecedence = function(result, parser) {
349349
* @param {Parser} parser - The parser instance (use for extracting locations)
350350
* @return {Function}
351351
*/
352-
AST.prototype.prepare = function(kind, docs, parser) {
352+
AST.prototype.prepare = function (kind, docs, parser) {
353353
let start = null;
354354
if (this.withPositions || this.withSource) {
355355
start = this.position(parser);
356356
}
357357
const self = this;
358358
// returns the node
359-
const result = function() {
359+
const result = function () {
360360
let location = null;
361361
const args = Array.prototype.slice.call(arguments);
362362
args.push(docs);
@@ -405,7 +405,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
405405
}
406406
AST.stack[++AST.stackUid] = {
407407
position: start,
408-
stack: new Error().stack.split("\n").slice(3, 5)
408+
stack: new Error().stack.split("\n").slice(3, 5),
409409
};
410410
result.stackUid = AST.stackUid;
411411
}
@@ -414,7 +414,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
414414
* Sets a list of trailing comments
415415
* @param {*} docs
416416
*/
417-
result.setTrailingComments = function(docs) {
417+
result.setTrailingComments = function (docs) {
418418
if (result.instance) {
419419
// already created
420420
result.instance.setTrailingComments(docs);
@@ -426,7 +426,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
426426
/**
427427
* Release a node without using it on the AST
428428
*/
429-
result.destroy = function(target) {
429+
result.destroy = function (target) {
430430
if (docs) {
431431
// release current docs stack
432432
if (target) {
@@ -446,7 +446,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
446446
return result;
447447
};
448448

449-
AST.prototype.checkNodes = function() {
449+
AST.prototype.checkNodes = function () {
450450
const errors = [];
451451
for (const k in AST.stack) {
452452
if (AST.stack.hasOwnProperty(k)) {
@@ -560,8 +560,8 @@ AST.prototype.checkNodes = function() {
560560
require("./ast/variadic"),
561561
require("./ast/while"),
562562
require("./ast/yield"),
563-
require("./ast/yieldfrom")
564-
].forEach(function(ctor) {
563+
require("./ast/yieldfrom"),
564+
].forEach(function (ctor) {
565565
AST.prototype[ctor.kind] = ctor;
566566
});
567567

src/ast/classconstant.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const ClassConstant = ConstantStatement.extends(KIND, function ClassConstant(
3535
* @param {Integer[]} flags
3636
* @return {void}
3737
*/
38-
ClassConstant.prototype.parseFlags = function(flags) {
38+
ClassConstant.prototype.parseFlags = function (flags) {
3939
if (flags[0] === -1) {
4040
this.visibility = IS_UNDEFINED;
4141
} else if (flags[0] === null) {

src/ast/declaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Declaration = Statement.extends(KIND, function Declaration(
3434
* @param {Integer[]} flags
3535
* @return {void}
3636
*/
37-
Declaration.prototype.parseFlags = function(flags) {
37+
Declaration.prototype.parseFlags = function (flags) {
3838
this.isAbstract = flags[2] === 1;
3939
this.isFinal = flags[2] === 2;
4040
if (this.kind !== "class") {

src/ast/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @property {Position} start
1313
* @property {Position} end
1414
*/
15-
const Location = function(source, start, end) {
15+
const Location = function (source, start, end) {
1616
this.source = source;
1717
this.start = start;
1818
this.end = end;

src/ast/node.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const Node = function Node(kind, docs, location) {
2727
* Attach comments to current node
2828
* @param {*} docs
2929
*/
30-
Node.prototype.setTrailingComments = function(docs) {
30+
Node.prototype.setTrailingComments = function (docs) {
3131
this.trailingComments = docs;
3232
};
3333

3434
/**
3535
* Destroying an unused node
3636
*/
37-
Node.prototype.destroy = function(node) {
37+
Node.prototype.destroy = function (node) {
3838
if (!node) {
3939
throw new Error(
4040
"Node already initialized, you must swap with another node"
@@ -67,7 +67,7 @@ Node.prototype.destroy = function(node) {
6767
* Includes current token position of the parser
6868
* @param {*} parser
6969
*/
70-
Node.prototype.includeToken = function(parser) {
70+
Node.prototype.includeToken = function (parser) {
7171
if (this.loc) {
7272
if (this.loc.end) {
7373
this.loc.end.line = parser.lexer.yylloc.last_line;
@@ -90,7 +90,7 @@ Node.prototype.includeToken = function(parser) {
9090
* @param {Function} constructor
9191
* @return {Function}
9292
*/
93-
Node.extends = function(type, constructor) {
93+
Node.extends = function (type, constructor) {
9494
constructor.prototype = Object.create(this.prototype);
9595
constructor.extends = this.extends;
9696
constructor.prototype.constructor = constructor;

src/ast/position.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @property {Number} column
1313
* @property {Number} offset
1414
*/
15-
const Position = function(line, column, offset) {
15+
const Position = function (line, column, offset) {
1616
this.line = line;
1717
this.column = column;
1818
this.offset = offset;

src/ast/propertystatement.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const PropertyStatement = Statement.extends(KIND, function PropertyStatement(
3636
* @param {Integer[]} flags
3737
* @return {void}
3838
*/
39-
PropertyStatement.prototype.parseFlags = function(flags) {
39+
PropertyStatement.prototype.parseFlags = function (flags) {
4040
if (flags[0] === -1) {
4141
this.visibility = IS_UNDEFINED;
4242
} else if (flags[0] === null) {

src/ast/typereference.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TypeReference.types = [
3434
"array",
3535
"callable",
3636
"iterable",
37-
"void"
37+
"void",
3838
];
3939

4040
module.exports = TypeReference;

src/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function combine(src, to) {
6666
* @property {AST} ast
6767
* @property {Object} tokens
6868
*/
69-
const engine = function(options) {
69+
const engine = function (options) {
7070
if (typeof this === "function") {
7171
return new this(options);
7272
}
@@ -109,7 +109,7 @@ const engine = function(options) {
109109
* @param {Buffer|String} buffer Input value that can be either a buffer or a string
110110
* @return {String} Returns the string from input
111111
*/
112-
const getStringBuffer = function(buffer) {
112+
const getStringBuffer = function (buffer) {
113113
return Buffer.isBuffer(buffer) ? buffer.toString() : buffer;
114114
};
115115

@@ -119,15 +119,15 @@ const getStringBuffer = function(buffer) {
119119
* @return {Engine}
120120
* @private
121121
*/
122-
engine.create = function(options) {
122+
engine.create = function (options) {
123123
return new engine(options);
124124
};
125125

126126
/**
127127
* Evaluate the buffer
128128
* @private
129129
*/
130-
engine.parseEval = function(buffer, options) {
130+
engine.parseEval = function (buffer, options) {
131131
const self = new engine(options);
132132
return self.parseEval(buffer);
133133
};
@@ -137,7 +137,7 @@ engine.parseEval = function(buffer, options) {
137137
* @param {String} buffer
138138
* @return {Program}
139139
*/
140-
engine.prototype.parseEval = function(buffer) {
140+
engine.prototype.parseEval = function (buffer) {
141141
this.lexer.mode_eval = true;
142142
this.lexer.all_tokens = false;
143143
buffer = getStringBuffer(buffer);
@@ -148,7 +148,7 @@ engine.prototype.parseEval = function(buffer) {
148148
* Static function that parse a php code with open/close tags
149149
* @private
150150
*/
151-
engine.parseCode = function(buffer, filename, options) {
151+
engine.parseCode = function (buffer, filename, options) {
152152
if (typeof filename === "object" && !options) {
153153
// retro-compatibility
154154
options = filename;
@@ -178,7 +178,7 @@ engine.parseCode = function(buffer, filename, options) {
178178
* @param {String} filename - Filename
179179
* @return {Program}
180180
*/
181-
engine.prototype.parseCode = function(buffer, filename) {
181+
engine.prototype.parseCode = function (buffer, filename) {
182182
this.lexer.mode_eval = false;
183183
this.lexer.all_tokens = false;
184184
buffer = getStringBuffer(buffer);
@@ -189,7 +189,7 @@ engine.prototype.parseCode = function(buffer, filename) {
189189
* Split the buffer into tokens
190190
* @private
191191
*/
192-
engine.tokenGetAll = function(buffer, options) {
192+
engine.tokenGetAll = function (buffer, options) {
193193
const self = new engine(options);
194194
return self.tokenGetAll(buffer);
195195
};
@@ -200,7 +200,7 @@ engine.tokenGetAll = function(buffer, options) {
200200
* @param {String} buffer
201201
* @return {String[]} - Each item can be a string or an array with following informations [token_name, text, line_number]
202202
*/
203-
engine.prototype.tokenGetAll = function(buffer) {
203+
engine.prototype.tokenGetAll = function (buffer) {
204204
this.lexer.mode_eval = false;
205205
this.lexer.all_tokens = true;
206206
buffer = getStringBuffer(buffer);

0 commit comments

Comments
 (0)