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

object-curly-spacing [2, 'never'] complains of Flow type annotation in function parameters #6940

Closed
turadg opened this issue Aug 19, 2016 · 1 comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@turadg
Copy link
Contributor

turadg commented Aug 19, 2016

What version of ESLint are you using?

3.3.1

What parser (default, Babel-ESLint, etc.) are you using?

Babel-ESLint

Please show your full configuration:

module.exports = {

  // base off Airbnb Javascript Style Guide
  // https://github.com/airbnb/javascript
  'extends': [
    'eslint-config-airbnb',
  ],

  'parser': 'babel-eslint',

  // subdirs should inherit from here
  'root': true,

  'plugins': [
    'flowtype',
  ],

  'rules': {
    // Flow stuff
    'flowtype/define-flow-type': 1,
    'flowtype/use-flow-type': 1,
    "flowtype/require-valid-file-annotation": [1, "always"], // 638 instances
    "flowtype/space-after-type-colon": [2, "always"],
    "flowtype/space-before-type-colon": [2, "never"],

    // tighten these Airbnb warnings to errors
    'react/jsx-indent': [2, 2],

    // errors on these that Airbnb style allows
    'react/no-danger': 2,
    'react/no-direct-mutation-state': 2,
    'react/jsx-curly-spacing': [2, 'never'],
    'react/jsx-no-duplicate-props': 2,

    // we like our closing brackets aligned with the start of the tag
    'react/jsx-closing-bracket-location': [2, {
      'nonEmpty': 'after-props',
      'selfClosing': 'tag-aligned',
    }],

    // tighten these Airbnb warnings to errors
    //
    'no-alert': 2,
    'no-constant-condition': 2,

    // errors on these that Airbnb style allows
    //
    'dot-location': [2, 'property'],
    'new-parens': 2,
    'no-array-constructor': 2,
    'no-bitwise': 2,
    'no-catch-shadow': 2,
    'no-extra-boolean-cast': 2,
    'no-label-var': 2,
    'no-restricted-syntax': [2, 'WithStatement'],
    'no-undef-init': 2,
    'no-useless-concat': 2,
    'space-unary-ops': [2, {'words': true, 'nonwords': false}],
    'object-curly-spacing': [2, 'never'],
    'import/default': 2,
    'import/named': 2,
    'import/namespace': 2,

    // change qualifiers
    //
    'comma-dangle': [2, 'always-multiline'],
    'curly': [2, 'all'],
    'dot-notation': [2, {'allowKeywords': true, 'allowPattern': '^[a-z]+(_[a-z]+)*$'}],
    'no-use-before-define': [2, 'nofunc'],
    'indent': [2, 2, {'SwitchCase': 1}],
    'no-unused-vars': [2, { "argsIgnorePattern": '^_' }],

    // These were added when we bumped the Airbnb rules.
    // Our code doesn't comply and we haven't decided whether we want it to.
    'space-before-function-paren': 0,
    'quote-props': 0,
    'no-param-reassign': 0,
    'no-else-return': 0,
    'space-before-function-paren': 0,
    'prefer-rest-params': 0,
    'no-restricted-syntax': 0,
    'prefer-template': 0,
    'no-underscore-dangle': 0,
    'jsx-a11y/img-has-alt': 0,
    'react/jsx-filename-extension': 0, // 107 instances
    'import/imports-first': 0, // 174 instances
    'import/prefer-default-export': 0, // 43 instances
    'import/no-extraneous-dependencies': 0, // 82 instances
    'react/require-extension': 0, // deprecated
    'import/no-named-as-default': 0, // 49 instances
    'react/no-find-dom-node': 0, // 31 instances, https://github.com/yannickcr/eslint-plugin-react/issues/678#issue-165177220
    'react/jsx-no-comment-textnodes': 0,
    'prefer-spread': 0,
    'import/newline-after-import': 0,
    'react/no-string-refs': 0,
    'import/no-named-as-default-member': 0,
    'no-mixed-operators': 0,
    'object-property-newline': 0, // 3 instances
    'no-undef': 0, // 1 instance
    'no-prototype-builtins': 0, // 3 instances
    'react/jsx-no-target-blank': 0, // 3 instances
    'no-continue': 0, // 1 instance
    'no-lonely-if': 0, // 1 instance
    'react/self-closing-comp': 0, // 1 instance
    'operator-assignment': 0, // 8 instances
    'jsx-a11y/label-has-for': 0, // 2 instances
    'no-path-concat': 0, // 1 instance

    // disable all these
    //
    'func-names': 0,
    'global-require': 0,
    'guard-for-in': 0,
    'id-length': 0,
    'max-len': 0, // soft wrap FTW
    'no-console': 0,
    'vars-on-top': 0,
    'no-duplicate-imports': 0, // we use import/no-duplicates instead, which handles flow type imports
  },
};

What did you do? Please include the actual source code causing the issue.

type Props = any;
function foo ({a, b}: Props) { // eslint-disable-line object-curly-spacing
  console.log(a, b);
}
foo({a: 0, b: 1});

What did you expect to happen?

That object-curly-spacing would not complain about function foo ({a, b}: Props) {. It's the style enforced by "flowtype/space-after-type-colon": [2, "always"].

What actually happened? Please include the actual, raw output from ESLint.

  32:23  error  There should be no space before 'Props'  object-curly-spacing

I've looked at the rule qualifiers in http://eslint.org/docs/rules/object-curly-spacing and neither seem to apply.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 19, 2016
@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 19, 2016
@mysticatea
Copy link
Member

mysticatea commented Aug 20, 2016

Thank you for this issue.

I confirmed it.

{
    "root": true,
    "parser": "babel-eslint",
    "env": {
        "es6": true
    },
    "rules": {
        "object-curly-spacing": ["error", "never"]
    }
}
type Props = any;
function foo ({a, b}: Props) {
}

ESTree spec has typeAnnotation (container only). Also, we have fixed a similar issue before (#5211).

I will work on this.

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 20, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants