Skip to content

Commit

Permalink
Merge pull request #24 from hildjj/plugin-issues
Browse files Browse the repository at this point in the history
Fix issues arising from inclusion in eslint-plugin
  • Loading branch information
hildjj committed Feb 18, 2024
2 parents 918186b + 90878a2 commit aaeb3b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
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]+

0 comments on commit aaeb3b4

Please sign in to comment.