Skip to content

Commit

Permalink
refactor(traverse): use camel case props internally (#3880)
Browse files Browse the repository at this point in the history
Small change to internals of `oxc_traverse` codegen. Use camel-case property names.
  • Loading branch information
overlookmotel committed Jun 24, 2024
1 parent 2045c92 commit 24979c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions crates/oxc_traverse/scripts/lib/parse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {readFile} from 'fs/promises';
import {join as pathJoin} from 'path';
import {fileURLToPath} from 'url';
import assert from 'assert';
import {typeAndWrappers} from './utils.mjs';
import {typeAndWrappers, snakeToCamel} from './utils.mjs';

const FILENAMES = ['js.rs', 'jsx.rs', 'literal.rs', 'ts.rs'];

Expand Down Expand Up @@ -145,7 +145,8 @@ function parseScopeArgs(argsStr, filename, lineIndex) {
}
assert(bracketCount === 0);

args[key] = argsStr.slice(0, index).trim();
const camelKey = key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
args[camelKey] = argsStr.slice(0, index).trim();
argsStr = argsStr.slice(index + 1);
if (argsStr === '') break;

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_traverse/scripts/lib/walk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function generateWalkForStruct(type, types) {
let scopeEnterField, enterScopeCode = '', exitScopeCode = '';
if (scopeArgs && scopeIdField) {
// Get field to enter scope before
const enterFieldName = scopeArgs.enter_scope_before;
const enterFieldName = scopeArgs.enterScopeBefore;
if (enterFieldName) {
scopeEnterField = visitedFields.find(field => field.name === enterFieldName);
assert(
Expand Down

0 comments on commit 24979c9

Please sign in to comment.