How to use the acorn-jsx.tokenizer function in acorn-jsx

To help you get started, we’ve selected a few acorn-jsx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hph / wings / src / ui / components / line / index.js View on Github external
export const collectTokens = string => {
  const tokens = [];
  let lastPos = 0;
  try {
    // eslint-disable-next-line no-restricted-syntax
    for (const token of tokenizer(string, tokenizerOptions)) {
      // Prepend empty space(s) as required.
      if (token.start > lastPos) {
        // eslint-disable-next-line fp/no-mutating-methods
        tokens.push({
          value: ' '.repeat(token.start - lastPos),
        });
      }

      // Set custom types for missing types.
      if (token.value === 'let') {
        // eslint-disable-next-line no-underscore-dangle
        token.type = tokenTypes._let;
      }
      if (token.value === 'from') {
        // eslint-disable-next-line no-underscore-dangle
        token.type = tokenTypes._from;

acorn-jsx

Modern, fast React.js JSX parser

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages