astro-eslint-parser 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +8 -1
- package/lib/index.js +14 -5
- package/lib/index.mjs +14 -5
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ declare class Context {
|
|
|
19
19
|
line: number;
|
|
20
20
|
column: number;
|
|
21
21
|
};
|
|
22
|
+
getIndexFromLoc(loc: {
|
|
23
|
+
line: number;
|
|
24
|
+
column: number;
|
|
25
|
+
}): number;
|
|
22
26
|
/**
|
|
23
27
|
* Get the location information of the given indexes.
|
|
24
28
|
*/
|
|
@@ -336,7 +340,10 @@ declare class ParseError extends SyntaxError {
|
|
|
336
340
|
/**
|
|
337
341
|
* Initialize this ParseError instance.
|
|
338
342
|
*/
|
|
339
|
-
constructor(message: string, offset: number
|
|
343
|
+
constructor(message: string, offset: number | {
|
|
344
|
+
line: number;
|
|
345
|
+
column: number;
|
|
346
|
+
}, ctx: Context);
|
|
340
347
|
}
|
|
341
348
|
|
|
342
349
|
/**
|
package/lib/index.js
CHANGED
|
@@ -174,10 +174,16 @@ var import_types = require("@typescript-eslint/types");
|
|
|
174
174
|
var ParseError = class extends SyntaxError {
|
|
175
175
|
constructor(message, offset, ctx) {
|
|
176
176
|
super(message);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
if (typeof offset === "number") {
|
|
178
|
+
this.index = offset;
|
|
179
|
+
const loc = ctx.getLocFromIndex(offset);
|
|
180
|
+
this.lineNumber = loc.line;
|
|
181
|
+
this.column = loc.column;
|
|
182
|
+
} else {
|
|
183
|
+
this.index = ctx.getIndexFromLoc(offset);
|
|
184
|
+
this.lineNumber = offset.line;
|
|
185
|
+
this.column = offset.column;
|
|
186
|
+
}
|
|
181
187
|
this.originalAST = ctx.originalAST;
|
|
182
188
|
}
|
|
183
189
|
};
|
|
@@ -1088,6 +1094,9 @@ var Context = class {
|
|
|
1088
1094
|
column: loc.column
|
|
1089
1095
|
};
|
|
1090
1096
|
}
|
|
1097
|
+
getIndexFromLoc(loc) {
|
|
1098
|
+
return this.locs.getIndexFromLoc(loc);
|
|
1099
|
+
}
|
|
1091
1100
|
getLocations(start, end) {
|
|
1092
1101
|
return {
|
|
1093
1102
|
range: [start, end],
|
|
@@ -1212,7 +1221,7 @@ function parse2(code, ctx) {
|
|
|
1212
1221
|
for (const { code: code2, text, location, severity } of result.diagnostics || []) {
|
|
1213
1222
|
if (severity === 1) {
|
|
1214
1223
|
ctx.originalAST = result.ast;
|
|
1215
|
-
throw new ParseError(`${text} [${code2}]`, location
|
|
1224
|
+
throw new ParseError(`${text} [${code2}]`, location, ctx);
|
|
1216
1225
|
}
|
|
1217
1226
|
}
|
|
1218
1227
|
if (!result.ast.children) {
|
package/lib/index.mjs
CHANGED
|
@@ -145,10 +145,16 @@ import { AST_TOKEN_TYPES, AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
|
145
145
|
var ParseError = class extends SyntaxError {
|
|
146
146
|
constructor(message, offset, ctx) {
|
|
147
147
|
super(message);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
if (typeof offset === "number") {
|
|
149
|
+
this.index = offset;
|
|
150
|
+
const loc = ctx.getLocFromIndex(offset);
|
|
151
|
+
this.lineNumber = loc.line;
|
|
152
|
+
this.column = loc.column;
|
|
153
|
+
} else {
|
|
154
|
+
this.index = ctx.getIndexFromLoc(offset);
|
|
155
|
+
this.lineNumber = offset.line;
|
|
156
|
+
this.column = offset.column;
|
|
157
|
+
}
|
|
152
158
|
this.originalAST = ctx.originalAST;
|
|
153
159
|
}
|
|
154
160
|
};
|
|
@@ -1059,6 +1065,9 @@ var Context = class {
|
|
|
1059
1065
|
column: loc.column
|
|
1060
1066
|
};
|
|
1061
1067
|
}
|
|
1068
|
+
getIndexFromLoc(loc) {
|
|
1069
|
+
return this.locs.getIndexFromLoc(loc);
|
|
1070
|
+
}
|
|
1062
1071
|
getLocations(start, end) {
|
|
1063
1072
|
return {
|
|
1064
1073
|
range: [start, end],
|
|
@@ -1183,7 +1192,7 @@ function parse2(code, ctx) {
|
|
|
1183
1192
|
for (const { code: code2, text, location, severity } of result.diagnostics || []) {
|
|
1184
1193
|
if (severity === 1) {
|
|
1185
1194
|
ctx.originalAST = result.ast;
|
|
1186
|
-
throw new ParseError(`${text} [${code2}]`, location
|
|
1195
|
+
throw new ParseError(`${text} [${code2}]`, location, ctx);
|
|
1187
1196
|
}
|
|
1188
1197
|
}
|
|
1189
1198
|
if (!result.ast.children) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-eslint-parser",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/ota-meshi/astro-eslint-parser#readme",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@astrojs/compiler": "^0.27.0",
|
|
50
|
+
"@astrojs/compiler": "^0.27.0 || ^0.28.0",
|
|
51
51
|
"@typescript-eslint/types": "^5.25.0",
|
|
52
52
|
"astrojs-compiler-sync": "^0.3.0",
|
|
53
53
|
"debug": "^4.3.4",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"eslint": "^8.15.0",
|
|
80
80
|
"eslint-config-prettier": "^8.3.0",
|
|
81
81
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
82
|
-
"eslint-plugin-astro": "^0.
|
|
82
|
+
"eslint-plugin-astro": "^0.20.0",
|
|
83
83
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
84
84
|
"eslint-plugin-json-schema-validator": "^4.0.0",
|
|
85
85
|
"eslint-plugin-jsonc": "^2.0.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"mocha-chai-jest-snapshot": "^1.1.3",
|
|
99
99
|
"nyc": "^15.1.0",
|
|
100
100
|
"prettier": "^2.0.5",
|
|
101
|
-
"prettier-plugin-astro": "^0.
|
|
101
|
+
"prettier-plugin-astro": "^0.6.0",
|
|
102
102
|
"prettier-plugin-svelte": "^2.7.0",
|
|
103
103
|
"semver": "^7.3.5",
|
|
104
104
|
"string-replace-loader": "^3.0.3",
|