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

Prettier support #230

Closed
theoludwig opened this issue Dec 9, 2020 · 0 comments
Closed

Prettier support #230

theoludwig opened this issue Dec 9, 2020 · 0 comments

Comments

@theoludwig
Copy link
Contributor

theoludwig commented Dec 9, 2020

What problem do you want to solve?

Making standard ecosystem easier to use!
As discussed in : standard/ts-standard#102, standard/standard#1356, standard/standard#811
There is already prettier-standard but it would be cool, if it could work out of the box for packages like standard, semistandard, standardx, ts-standard etc.

What do you think is the correct solution to this problem?

Warning: It is a breaking change because, packages made with standard-engine would need to provide a prettierConfig path and a prettier instance.

  • New options.js with prettierConfig
const eslint = require('eslint')
const prettier = require("prettier")
const path = require('path')
const pkg = require('./package.json')

module.exports = {
  // homepage, version and bugs pulled from package.json
  version: pkg.version,
  homepage: pkg.homepage,
  bugs: pkg.bugs.url,
  eslint: eslint, // pass any version of eslint >= 1.0.0
  prettier: prettier, // pass any version of prettier >= 2.0.0
  cmd: 'pocketlint', // should match the "bin" key in your package.json
  tagline: 'Live by your own standards!', // displayed in output --help
  eslintConfig: {
    configFile: path.join(__dirname, 'eslintrc.json')
  },
  prettierConfig: {
   configFile: path.join(__dirname, '.prettierrc.json')
  },
  cwd: '' // current working directory, passed to eslint
}
  • New CLI flag --format

  • New options for engine.lintFiles (format: boolean):

{
  // unique to lintText
  filename: '',         // path of file containing the text being linted

  // common to lintText and lintFiles
  cwd: '',              // current working directory (default: process.cwd())
  fix: false,           // automatically fix problems
  format: true,         // aggressively format code for consistency
  extensions: [],       // file extensions to lint (has sane defaults)
  globals: [],          // custom global variables to declare
  plugins: [],          // custom eslint plugins
  envs: [],             // custom eslint environment
  parser: '',           // custom js parser (e.g. babel-eslint)
  usePackageJson: true, // use options from nearest package.json?
  useGitIgnore: true    // use file ignore patterns from .gitignore?
}

If format: true, it means we use the prettier api to format the code and also once prettier formatting is done, we also lint the files, so basically, if format: true, then implicitly fix: true because if we format we also lint.

Are you willing to submit a pull request to implement this change?

Yes!

@theoludwig theoludwig self-assigned this Dec 9, 2020
@theoludwig theoludwig added this to the 15.0.0 milestone Sep 5, 2021
@theoludwig theoludwig modified the milestones: 15.0.0, 16.0.0 Dec 20, 2021
@theoludwig theoludwig removed their assignment Jun 13, 2022
@theoludwig theoludwig removed this from the 16.0.0 milestone Jun 13, 2022
@theoludwig theoludwig closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant