Skip to content

Commit e147de9

Browse files
🐛 fix non-standard node.start to node.range[0] (#30)
1 parent 160d35b commit e147de9

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install Node.js
1818
uses: actions/setup-node@v1
1919
with:
20-
node: 12.x
20+
node: 14.x
2121
- name: Install Packages
2222
run: npm install
2323
- name: Lint
@@ -28,37 +28,37 @@ jobs:
2828

2929
strategy:
3030
matrix:
31-
eslint: [6.x]
31+
eslint: [7]
3232
node: [14.x]
3333
os: [ubuntu-latest]
3434
include:
3535
# On other platforms
36-
- eslint: 6.x
36+
- eslint: 7
3737
node: 14.x
3838
os: windows-latest
39-
- eslint: 6.x
39+
- eslint: 7
4040
node: 14.x
4141
os: macos-latest
4242
# On old Node.js versions
43-
- eslint: 6.x
43+
- eslint: 7
4444
node: 12.x
4545
os: ubuntu-latest
46-
- eslint: 6.x
46+
- eslint: 7
4747
node: 10.x
4848
os: ubuntu-latest
49-
- eslint: 6.x
50-
node: 8.x
51-
os: ubuntu-latest
5249
# On old ESLint versions
53-
- eslint: 5.x
50+
- eslint: 6
51+
node: 14.x
52+
os: ubuntu-latest
53+
- eslint: 5
5454
node: 14.x
5555
os: ubuntu-latest
56-
- eslint: 4.x
56+
- eslint: 4
5757
node: 14.x
5858
os: ubuntu-latest
5959
# On the minimum supported ESLint/Node.js version
60-
- eslint: 4.x
61-
node: "8.0.0"
60+
- eslint: 4
61+
node: 8.10.0
6262
os: ubuntu-latest
6363

6464
runs-on: ${{ matrix.os }}

lib/rules/no-unicode-codepoint-escapes.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ module.exports = {
4040

4141
/**
4242
* find code point escape, and report
43-
* @param {string} text text
4443
* @param {Node} node node
4544
* @returns {void}
4645
*/
47-
function findAndReport(text, node) {
46+
function findAndReport(node) {
47+
const text = sourceCode.getText(node)
4848
for (const match of codePointEscapeSearchGenerator(text)) {
4949
const start = match.index
5050
const end = start + match[0].length
51-
const range = [start + node.start, end + node.start]
51+
const range = [start + node.range[0], end + node.range[0]]
5252
context.report({
5353
node,
5454
loc: {
@@ -85,15 +85,15 @@ module.exports = {
8585

8686
return {
8787
Identifier(node) {
88-
findAndReport(sourceCode.getText(node), node)
88+
findAndReport(node)
8989
},
9090
Literal(node) {
9191
if (typeof node.value === "string") {
92-
findAndReport(node.raw, node)
92+
findAndReport(node)
9393
}
9494
},
95-
TemplateElement(elementNode) {
96-
findAndReport(elementNode.value.raw, elementNode)
95+
TemplateElement(node) {
96+
findAndReport(node)
9797
},
9898
}
9999
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"codecov": "^3.5.0",
2525
"eslint": "^6.2.2",
2626
"eslint4b": "^6.2.2",
27-
"espree": "^6.1.1",
27+
"espree": "^7.0.0",
2828
"globals": "^12.0.0",
2929
"mocha": "^6.2.0",
3030
"npm-run-all": "^4.1.5",

tests/lib/rules/no-unicode-codepoint-escapes.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ b="\\uD842\\uDFB7"
133133
"ES2015 Unicode code point escape sequences are forbidden.",
134134
line: 2,
135135
column: 8,
136-
nodeType: "TemplateElement",
137136
endLine: 2,
138137
endColumn: 16,
139138
},
@@ -142,7 +141,6 @@ b="\\uD842\\uDFB7"
142141
"ES2015 Unicode code point escape sequences are forbidden.",
143142
line: 2,
144143
column: 16,
145-
nodeType: "TemplateElement",
146144
endLine: 2,
147145
endColumn: 24,
148146
},
@@ -151,7 +149,6 @@ b="\\uD842\\uDFB7"
151149
"ES2015 Unicode code point escape sequences are forbidden.",
152150
line: 3,
153151
column: 4,
154-
nodeType: "Literal",
155152
endLine: 3,
156153
endColumn: 13,
157154
},

0 commit comments

Comments
 (0)