standard / standard

🌟 JavaScript Style Guide, with linter & automatic code fixer
https://standardjs.com
MIT License
29.09k stars 2.33k forks source link

how to easily use standard with prettier? #996

Open capaj opened 7 years ago

capaj commented 7 years ago

I'd like to use prettier to format my code and standard.js for checking unused variables, triple equals and all it's rules. There is one problem though-in all of my repos, I need to disable few standard.js rules to make it work-like this:

{
  "extends": ["standard", "plugin:flowtype/recommended"],
  "rules": {
    "prettier/prettier": "error",
    "space-before-function-paren": "off",
    "standard/computed-property-even-spacing": "off",
    "flowtype/generic-spacing": "off",
    "no-unexpected-multiline": "off",
    "indent": "off",
    "jsx-quotes": "off"
  },
  "parser": "babel-eslint",
  "plugins": ["flowtype", "prettier"],
  "root": true
}

is there any way to get only standard rules which are not about formatting? Something like standard-config-noformatting that I could extend instead?

whphhg commented 7 years ago

I don't want to derail this issue, but can you please share further which packages are required for this to work?

I've been using prettier-standard and it was great so far, but after the update to 7.0.1 I ran into https://github.com/sheerun/prettier-standard/issues/30 which is causing some issues.

capaj commented 7 years ago

@whphhg there are quite a few. I should probably make a boilerplate or maybe try t oseparate those standard.js rules into standard-config-noformatting

"devDependencies": {
    "babel-eslint": "^8.0.1",
    "eslint": "^4.8.0",
    "eslint-config-prettier": "^2.6.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-config-standard-jsx": "^4.0.2",
    "eslint-plugin-flowtype": "^2.37.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-node": "^5.2.0",
    "eslint-plugin-prettier": "^2.3.1",
    "eslint-plugin-promise": "^3.5.0",
    "eslint-plugin-react": "^7.4.0",
    "eslint-plugin-standard": "^3.0.1",
    "husky": "^0.14.3",
    "lint-staged": "^4.2.3",
    "prettier": "^1.7.3"
  },
  "lint-staged": {
    "*.{js,json,css}": ["prettier --write", "git add"],
    "*.js": ["eslint --fix", "git add"]
  }
whphhg commented 7 years ago

Thanks for sharing and updating the .eslintrc!

It's longer than my current devDep's but at least I know exactly what's going on and how to alter it through .eslintrc & .prettierrc (plus it's nicely grouped by eslint-).

jasonkarns commented 6 years ago

FWIW, I'm having success with following lint script:

lint
    prettier-standard $npm_package_directories_src'/**/*.js' && standard --fix | standard-tap
lydell commented 6 years ago

Sounds like you're looking for https://github.com/prettier/eslint-config-prettier?

eddiemonge commented 6 years ago

duplicate of https://github.com/standard/standard/issues/811 ?

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

mightyiam commented 1 year ago

1872 would make standard easier to use with any formatter.