svelte-eslint-parser
Advanced tools
@@ -6,2 +6,19 @@ "use strict"; | ||
| const common_1 = require("./common"); | ||
| /** Get start index of block */ | ||
| function startBlockIndex(code, endIndex) { | ||
| return (0, common_1.lastIndexOf)(code, (c, index) => { | ||
| if (c !== "{") { | ||
| return false; | ||
| } | ||
| for (let next = index + 1; next < code.length; next++) { | ||
| const nextC = code[next]; | ||
| if (!nextC.trim()) { | ||
| continue; | ||
| } | ||
| return (code.startsWith("#if", next) || | ||
| code.startsWith(":else", next)); | ||
| } | ||
| return false; | ||
| }, endIndex); | ||
| } | ||
| /** Convert for IfBlock */ | ||
@@ -12,3 +29,3 @@ function convertIfBlock(node, parent, ctx) { | ||
| const nodeStart = node.elseif | ||
| ? ctx.code.lastIndexOf("{", node.start) | ||
| ? startBlockIndex(ctx.code, node.start - 1) | ||
| : node.start; | ||
@@ -29,3 +46,3 @@ const ifBlock = Object.assign({ type: "SvelteIfBlock", elseif: Boolean(node.elseif), expression: null, children: [], else: null, parent }, ctx.getConvertLocation({ start: nodeStart, end: node.end })); | ||
| } | ||
| const elseStart = ctx.code.lastIndexOf("{", node.else.start); | ||
| const elseStart = startBlockIndex(ctx.code, node.else.start - 1); | ||
| const elseBlock = Object.assign({ type: "SvelteElseBlock", children: [], parent: ifBlock }, ctx.getConvertLocation({ | ||
@@ -94,3 +111,3 @@ start: elseStart, | ||
| } | ||
| const elseStart = ctx.code.lastIndexOf("{", node.else.start); | ||
| const elseStart = startBlockIndex(ctx.code, node.else.start - 1); | ||
| const elseBlock = Object.assign({ type: "SvelteElseBlock", children: [], parent: eachBlock }, ctx.getConvertLocation({ | ||
@@ -97,0 +114,0 @@ start: elseStart, |
@@ -5,3 +5,3 @@ import type ESTree from "estree"; | ||
| /** lastIndexOf */ | ||
| export declare function lastIndexOf(str: string, search: (c: string) => boolean, end: number): number; | ||
| export declare function lastIndexOf(str: string, search: (c: string, index: number) => boolean, end: number): number; | ||
| export declare function getWithLoc<N extends ESTree.Comment>(node: N): N & { | ||
@@ -8,0 +8,0 @@ start: number; |
@@ -19,3 +19,3 @@ "use strict"; | ||
| const c = str[index]; | ||
| if (search(c)) { | ||
| if (search(c, index)) { | ||
| return index; | ||
@@ -22,0 +22,0 @@ } |
+20
-20
| { | ||
| "name": "svelte-eslint-parser", | ||
| "version": "0.6.0", | ||
| "version": "0.6.1", | ||
| "description": "Svelte parser for ESLint", | ||
@@ -42,3 +42,3 @@ "main": "lib/index.js", | ||
| "dependencies": { | ||
| "eslint-scope": "^6.0.0", | ||
| "eslint-scope": "^7.0.0", | ||
| "eslint-visitor-keys": "^3.0.0", | ||
@@ -52,4 +52,4 @@ "espree": "^9.0.0" | ||
| "@ota-meshi/eslint-plugin": "^0.10.0", | ||
| "@ota-meshi/eslint-plugin-svelte": "^0.11.0", | ||
| "@types/eslint": "^7.2.0", | ||
| "@ota-meshi/eslint-plugin-svelte": "^0.14.0", | ||
| "@types/eslint": "^8.0.0", | ||
| "@types/eslint-scope": "^3.7.0", | ||
@@ -59,9 +59,9 @@ "@types/eslint-visitor-keys": "^1.0.0", | ||
| "@types/node": "^16.0.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.0.0", | ||
| "@typescript-eslint/parser": "^5.0.0", | ||
| "code-red": "^0.2.0", | ||
| "eslint": "^8.0.0", | ||
| "eslint-config-prettier": "^8.0.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.4.0", | ||
| "@typescript-eslint/parser": "^5.4.0", | ||
| "code-red": "^0.2.3", | ||
| "eslint": "^8.2.0", | ||
| "eslint-config-prettier": "^8.3.0", | ||
| "eslint-plugin-eslint-comments": "^3.2.0", | ||
| "eslint-plugin-json-schema-validator": "^2.0.0", | ||
| "eslint-plugin-json-schema-validator": "^2.1.6", | ||
| "eslint-plugin-jsonc": "^2.0.0", | ||
@@ -71,18 +71,18 @@ "eslint-plugin-node": "^11.1.0", | ||
| "eslint-plugin-prettier": "^4.0.0", | ||
| "eslint-plugin-regexp": "^1.0.0", | ||
| "eslint-plugin-svelte3": "^3.2.0", | ||
| "eslint-plugin-vue": "^8.0.0", | ||
| "eslint-plugin-regexp": "^1.5.0", | ||
| "eslint-plugin-svelte3": "^3.2.1", | ||
| "eslint-plugin-vue": "^8.0.3", | ||
| "estree-walker": "^3.0.0", | ||
| "locate-character": "^2.0.5", | ||
| "magic-string": "^0.25.7", | ||
| "mocha": "^9.0.0", | ||
| "mocha": "^9.1.3", | ||
| "nyc": "^15.1.0", | ||
| "prettier": "^2.0.5", | ||
| "prettier-plugin-svelte": "^2.3.0", | ||
| "string-replace-loader": "^3.0.1", | ||
| "svelte": "^3.37.0", | ||
| "ts-node": "^10.0.0", | ||
| "typescript": "^4.0.0", | ||
| "vue-eslint-parser": "^8.0.0" | ||
| "prettier-plugin-svelte": "^2.5.0", | ||
| "string-replace-loader": "^3.0.3", | ||
| "svelte": "^3.44.1", | ||
| "ts-node": "^10.4.0", | ||
| "typescript": "~4.5.0-0", | ||
| "vue-eslint-parser": "^8.0.1" | ||
| } | ||
| } |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
148569
0.38%3557
0.48%+ Added
- Removed
Updated