mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 05:00:21 +00:00

We have been stalled on ESLint 3.8.0 for some time. Current ESLint is 3.13.0. We have been unable to upgrade because of more aggressive reporting on some rules, including indentation. ESLint configuration options and bugfixes are now such that we can reasonably upgrade. PR-URL: https://github.com/nodejs/node/pull/10561 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
20 lines
1.3 KiB
JavaScript
20 lines
1.3 KiB
JavaScript
// Copyright 2014, 2015, 2016 Simon Lydell
|
|
// X11 (“MIT”) Licensed. (See LICENSE.)
|
|
|
|
// This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
// (run `npm run build`).
|
|
module.exports = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]{1,6}\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g
|
|
|
|
module.exports.matchToToken = function(match) {
|
|
var token = {type: "invalid", value: match[0]}
|
|
if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
|
|
else if (match[ 5]) token.type = "comment"
|
|
else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
|
|
else if (match[ 8]) token.type = "regex"
|
|
else if (match[ 9]) token.type = "number"
|
|
else if (match[10]) token.type = "name"
|
|
else if (match[11]) token.type = "punctuator"
|
|
else if (match[12]) token.type = "whitespace"
|
|
return token
|
|
}
|