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

Contradicting doc (option "always") for semicolon #163

Closed
Splines opened this issue Nov 17, 2023 · 4 comments
Closed

Contradicting doc (option "always") for semicolon #163

Splines opened this issue Nov 17, 2023 · 4 comments

Comments

@Splines
Copy link

Splines commented Nov 17, 2023

In the docs for semi, you state that always was the default option.

* `"always"` (default) requires semicolons at the end of statements

However, when I use the following configuration in .eslintrc.js:

const stylistic = require("@stylistic/eslint-plugin");

const customized = stylistic.configs.customize({
  indent: 2,
  quotes: "double",
});

module.exports = {
  root: true,
  parserOptions: {
    ecmaVersion: 2024,
    sourceType: "module",
  },
  env: {
    browser: true,
    jquery: true,
  },
  extends: "eslint:recommended",
  plugins: [
    "@stylistic",
  ],
  rules: {
    ...customized.rules,
    "no-unused-vars": "warn",
  },
};

I get errors for having semicolons ("Extra semicolon"), such that I manually have to set

const customized = stylistic.configs.customize({
  indent: 2,
  quotes: "double",
  semi: "always",
});

I don't know but maybe this is related to this line?

@Splines Splines changed the title Contradicting doc & style Contradicting doc (option "always") for semicolon Nov 17, 2023
@antfu
Copy link
Member

antfu commented Nov 17, 2023

always is the rule's default value. This means that if you do 'semi': 'error' it will be always. While you are using the config preset, and the default is false, which is stated in https://eslint.style/guide/config-presets#pre-configured

@Splines
Copy link
Author

Splines commented Nov 17, 2023

Ok thanks, then I misunderstood the docs for the Configuration Factory:

We want to provide shared configurations to simplify the usage, while still allowing you to customize the rules to your own preferences.

I understood it like this: if you don't specify the key, we will use our default value (hence the word: "shared" configuration), otherwise you can customize it by specifying the key yourself. But apparently that's not the case.

Is there a way to import all of the style rules without having to manually specifying each key in the config? I haven't seen such an option yet.

@antfu antfu closed this as completed in 9996a21 Nov 17, 2023
@antfu
Copy link
Member

antfu commented Nov 17, 2023

I am not sure if it's a good idea to enable all rules, but sure we could have a preset for that

@antfu antfu mentioned this issue Nov 17, 2023
3 tasks
@antfu
Copy link
Member

antfu commented Nov 17, 2023

Opened #164 for tracking that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants