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

Adding custom rules to standard #1016

Closed
sebasgarcep opened this issue Nov 13, 2017 · 2 comments

Comments

@sebasgarcep
Copy link

commented Nov 13, 2017

Is there a way to add custom rules to standard through the package.json config without using standardx. I'm using the standard extension on visual studio code and I want something that works out of the box even if I change computers.

@Flet

This comment has been minimized.

Copy link
Member

commented Nov 13, 2017

Part of the philosophy of standard is:

No configuration. The easiest way to enforce consistent style in your project. Just drop it in.
No decisions to make. No .eslintrc, .jshintrc, or .jscsrc files to manage. It just works.

That being said, there are a few ways to do what you're trying to do.

One way to do it while maintaining really great support in IDEs/editors is to switch to using eslint directly with the eslint-config-standard configuration.

Here is how to do it:

  1. Install necessary packages:
    Run this command to save the required packages to devDependencies:
npm install --save-dev eslint@3 eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node
  1. Add config to package.json
    Add this key to package.json to enable the eslint-config-standard config:
"eslintConfig": {
  "extends": "standard"
}
  1. Use eslint for your linting needs.
    Just run eslint and eslint --fix for your linting needs. There is fantastic support for eslint in IDEs including vscode :)

  2. Tweak stuff
    Prefer double quotes everywhere? Override the rule by adding it to the config in package.json

"eslintConfig": {
  "extends": "standard",
  "rules": {
    "quotes": ["error", "double"]
  }
}

Its also possible to put config elsewhere (like .eslintrc). Check out the eslint docs for all the details: https://eslint.org/docs/user-guide/configuring

I hope this info helps! I'm closing this issue now, but feel free to comment!

P.S. adding standardx support to the vscode plugin for standard is a good idea! I opened an issue on that repo to see what they think! :) standard/vscode-standardjs#49

@Flet Flet closed this Nov 13, 2017

@sebasgarcep

This comment has been minimized.

Copy link
Author

commented Nov 13, 2017

Thanks @Flet for your answer!

I want to point out that I'm ok with how standard works right now for vanilla JS and the rules I want to add are React-specific. I find it confusing that standard already covers JSX but not React, specially when these two are almost always used together. It would be nice to include some react rules, or at least allow a way to activate these rules.

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.