Skip to content

Commit

Permalink
Merge pull request #128 from liuxingbaoyu/eslint-indent
Browse files Browse the repository at this point in the history
chore: add eslint rules
  • Loading branch information
jviereck authored Jun 28, 2022
2 parents ace5e55 + 5b94203 commit 5215b8d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports = {
},

rules: {
'indent': ['warn', 2, { "SwitchCase": 1 }],
"space-infix-ops": ["warn", { "int32Hint": false }],

"no-cond-assign": ["off"],
"no-useless-escape": ["off"],
"no-empty": ["off"],
Expand Down
40 changes: 20 additions & 20 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@
// Unicode surrogate pair
pos++;
return createValue(
'symbol',
(first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000,
pos - 2, pos);
'symbol',
(first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000,
pos - 2, pos);
}
}
}
Expand Down Expand Up @@ -1234,24 +1234,24 @@

// Check if both the from and atomTo have codePoints.
if (!('codePoint' in atom) || !('codePoint' in atomTo)) {
if (!isUnicodeMode) {
// If not, don't create a range but treat them as
// `atom` `-` `atom` instead.
//
// SEE: https://tc39.es/ecma262/#sec-regular-expression-patterns-semantics
// NonemptyClassRanges::ClassAtom-ClassAtomClassRanges
// CharacterRangeOrUnion
res = [atom, dash, atomTo];
} else {
// With unicode flag, both sides must have codePoints if
// one side has a codePoint.
//
// SEE: https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors
// NonemptyClassRanges :: ClassAtom - ClassAtom ClassRanges
bail('invalid character class');
}
if (!isUnicodeMode) {
// If not, don't create a range but treat them as
// `atom` `-` `atom` instead.
//
// SEE: https://tc39.es/ecma262/#sec-regular-expression-patterns-semantics
// NonemptyClassRanges::ClassAtom-ClassAtomClassRanges
// CharacterRangeOrUnion
res = [atom, dash, atomTo];
} else {
// With unicode flag, both sides must have codePoints if
// one side has a codePoint.
//
// SEE: https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors
// NonemptyClassRanges :: ClassAtom - ClassAtom ClassRanges
bail('invalid character class');
}
} else {
res = [createClassRange(atom, atomTo, from, to)];
res = [createClassRange(atom, atomTo, from, to)];
}

if (classRanges.type === 'empty') {
Expand Down
2 changes: 1 addition & 1 deletion tools/generate-identifier-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var version = '11.0.0'; // note: also update `package.json` when this changes

// Shorthand function
var get = function(what) {
return require('unicode-' + version + '/' + what + '/code-points');
return require('unicode-' + version + '/' + what + '/code-points');
};

// Get the Unicode properties needed to construct the regex.
Expand Down

0 comments on commit 5215b8d

Please sign in to comment.