Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues arising from inclusion in eslint-plugin #24

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const visitorKeys = {
Program: ["body", "comments"],
grammar: ["imports", "topLevelInitializer", "initializer", "rules"],
grammar_import: ["what", "from"],
binding: [],
binding: ["id"],
import_binding: ["binding"],
import_binding_all: ["binding"],
import_binding_default: ["binding"],
Expand Down Expand Up @@ -125,7 +125,7 @@ export interface ImportBindingRename extends BaseNode<"import_binding_rename"> {
}

export interface Binding extends BaseNode<"binding"> {
id?: string;
id?: Name;
}

export type ImportModuleSpecifier = QuotedString<"import_module_specifier">;
Expand Down
6 changes: 3 additions & 3 deletions src/parser.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ ModuleExportName
}

BindingIdentifier = id:IdentifierName {
if (reservedWords.indexOf(id[0]) >= 0) {
error(`Binding identifier can't be a reserved word "${id[0]}"`, id[1]);
if (reservedWords.indexOf(id.value) >= 0) {
error(`Binding identifier can't be a reserved word "${id.value}"`, id.loc);
}
return id[0];
return id;
}

TopLevelInitializer
Expand Down
2 changes: 1 addition & 1 deletion src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type VisitorFunction<T, U extends AST.Node> =
type VisitorFunctionOptional<T, U extends AST.Node> =
(node: U, opts?: VisitorOptions<T>) => T | undefined;

interface VisitorFunctionMap<T> {
export interface VisitorFunctionMap<T> {
// This is the only one with optional options.
"*"?: VisitorFunctionOptional<T, AST.Node>;
Program?: VisitorFunctionOptional<T, AST.Program>;
Expand Down
10 changes: 3 additions & 7 deletions test/fixtures/csv.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import {_} from './space.js'
{
let lineNum = 0;
}
csv = @line|0..{ return Infinity }, EOL| EOL*
csv = @line|0..{ return 10000 }, EOL|

// Each successive line requires at least one more field.
line = fields:field|lineNum.., "," _ | {
lineNum++;
return fields;
}
line = field|lineNum.., "," _ |

field
= '"' @$[^"]* '"'
/ $[^,"]*
/ $[^,"\r\n]*

EOL = [\r\n]+