-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Chore: Extracted fixture parser * Fix: adapted new-paren rule so it can handle TS (fixes #7817)
- Loading branch information
1 parent
df0b06b
commit 0fc24f7
Showing
5 changed files
with
164 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
|
||
/** | ||
* Gets the path to the specified parser. | ||
* | ||
* @param {string[]} arguments - The path containing the parser. | ||
* @returns {string} The path to the specified parser. | ||
*/ | ||
module.exports = function parser() { | ||
const parts = Array.from(arguments); | ||
const name = parts.pop(); | ||
|
||
return path.resolve(__dirname, "parsers", parts.join(path.sep), `${name}.js`); | ||
}; |
136 changes: 136 additions & 0 deletions
136
tests/fixtures/parsers/typescript-parsers/new-parens.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
"use strict"; | ||
|
||
// new Storage<RootState>('state'); | ||
|
||
exports.parse = () => ({ | ||
type: "Program", | ||
range: [0, 32], | ||
loc: { | ||
start: { line: 1, column: 0 }, | ||
end: { line: 1, column: 32 } | ||
}, | ||
body: [ | ||
{ | ||
type: "ExpressionStatement", | ||
range: [0, 32], | ||
loc: { | ||
start: { line: 1, column: 0 }, | ||
end: { line: 1, column: 32 } | ||
}, | ||
expression: { | ||
type: "NewExpression", | ||
range: [0, 31], | ||
loc: { | ||
start: { line: 1, column: 0 }, | ||
end: { line: 1, column: 31 } | ||
}, | ||
callee: { | ||
type: "Identifier", | ||
range: [4, 11], | ||
loc: { | ||
start: { line: 1, column: 4 }, | ||
end: { line: 1, column: 11 } | ||
}, | ||
name: "Storage" | ||
}, | ||
arguments: [ | ||
{ | ||
type: "Literal", | ||
range: [23, 30], | ||
loc: { | ||
start: { line: 1, column: 23 }, | ||
end: { line: 1, column: 30 } | ||
}, | ||
value: "state", | ||
raw: "'state'" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
sourceType: "script", | ||
tokens: [ | ||
{ | ||
type: "Keyword", | ||
value: "new", | ||
range: [0, 3], | ||
loc: { | ||
start: { line: 1, column: 0 }, | ||
end: { line: 1, column: 3 } | ||
} | ||
}, | ||
{ | ||
type: "Identifier", | ||
value: "Storage", | ||
range: [4, 11], | ||
loc: { | ||
start: { line: 1, column: 4 }, | ||
end: { line: 1, column: 11 } | ||
} | ||
}, | ||
{ | ||
type: "Punctuator", | ||
value: "<", | ||
range: [11, 12], | ||
loc: { | ||
start: { line: 1, column: 11 }, | ||
end: { line: 1, column: 12 } | ||
} | ||
}, | ||
{ | ||
type: "Identifier", | ||
value: "RootState", | ||
range: [12, 21], | ||
loc: { | ||
start: { line: 1, column: 12 }, | ||
end: { line: 1, column: 21 } | ||
} | ||
}, | ||
{ | ||
type: "Punctuator", | ||
value: ">", | ||
range: [21, 22], | ||
loc: { | ||
start: { line: 1, column: 21 }, | ||
end: { line: 1, column: 22 } | ||
} | ||
}, | ||
{ | ||
type: "Punctuator", | ||
value: "(", | ||
range: [22, 23], | ||
loc: { | ||
start: { line: 1, column: 22 }, | ||
end: { line: 1, column: 23 } | ||
} | ||
}, | ||
{ | ||
type: "String", | ||
value: "'state'", | ||
range: [23, 30], | ||
loc: { | ||
start: { line: 1, column: 23 }, | ||
end: { line: 1, column: 30 } | ||
} | ||
}, | ||
{ | ||
type: "Punctuator", | ||
value: ")", | ||
range: [30, 31], | ||
loc: { | ||
start: { line: 1, column: 30 }, | ||
end: { line: 1, column: 31 } | ||
} | ||
}, | ||
{ | ||
type: "Punctuator", | ||
value: ";", | ||
range: [31, 32], | ||
loc: { | ||
start: { line: 1, column: 31 }, | ||
end: { line: 1, column: 32 } | ||
} | ||
} | ||
], | ||
comments: [] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters