How to use prettier-eslint - 8 common examples

To help you get started, we’ve selected a few prettier-eslint 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 FindHotel / opticks / src / transform / CSSinCSS.js View on Github external
}
    })
    .toSource()

  // HACK to remove dangling ${} after clean up
  // TODO: remove CSS calls from AST instead of with comments
  const cleanSource = newSource
    .replace(/[\s]+\$\{\/\/TOGGLE_REMOVE[\s]+(css)?`/gm, '')
    .replace(/`\/\*TOGGLE_REMOVE\*\/}[\s]*/gm, '')

  if (skipCodeFormatting) {
    return cleanSource
  }

  try {
    return format({
      text: cleanSource,
      prettierOptions: {
        parser: 'flow'
      },
      filePath: eslintConfigPath || ESLINT_CONFIG_PATH
    })
  } catch (e) {
    console.error('file path', file.path)
    return cleanSource
  }
}
github kvz / invig / src / Invig.js View on Github external
return new Promise(async (resolve, reject) => {
      scrolex.stick('Making Pretty', { components: `invig>${srcPath}` })
      srcPath = srcPath.replace(/\.coffee$/, '.js')
      const sourceCode = await fs.readFile(srcPath, 'utf8')
      const options = {
        text           : sourceCode,
        eslintConfig,
        prettierOptions: {
          bracketSpacing: true,
        },
        fallbackPrettierOptions: {
          singleQuote: true,
          printWidth : 120,
        },
      }
      const code = format(options)
      if (this.opts.dryrun) resolve()
      fs.outputFile(srcPath, code).then(resolve).catch(reject)
    })
  }
github mcuking / vue2react / src / output.ts View on Github external
'space-before-function-paren': [2, 'always'],
          'padding-line-between-statements': [
            2,
            { blankLine: 'always', prev: 'import', next: 'export' }
          ],
          'lines-around-comment': [2, { beforeLineComment: true }],
          'no-console': 0,
          'no-empty': 0,
          'no-unused-vars': 0,
          'no-constant-condition': 0,
          'no-trailing-spaces': 0
        }
      }
    };

    const formattedCode = format(options);
    fs.writeFileSync(target, formattedCode);
    return;
  }

  fs.writeFileSync(target, code);
}

prettier-eslint

Formats your JavaScript using prettier followed by eslint --fix

MIT
Latest version published 10 months ago

Package Health Score

77 / 100
Full package analysis

Popular prettier-eslint functions