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 node type changes [$10] #3763

Closed
jonathanKingston opened this issue Sep 12, 2015 · 11 comments
Closed

object-curly-spacing node type changes [$10] #3763

jonathanKingston opened this issue Sep 12, 2015 · 11 comments
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 bounty Someone has posted a bounty for this issue on BountySource enhancement This change enhances an existing feature of ESLint good first issue Good for people who haven't worked on ESLint before help wanted The team would welcome a contribution from the community for this issue rule Relates to ESLint's core rules

Comments

@jonathanKingston
Copy link
Contributor

It appears common place to have object definitions as without spaces but import statements with spaces:

import { x } from y;

and

var me  = {x: 12};

So I suggest adding in the following properties to this rule to allow granular control:

            "ObjectPattern": {
                "enum": ["always", "never"]
            },
            "ObjectExpression": {
                "enum": ["always", "never"]
            },
            "ImportDeclaration": {
                "enum": ["always", "never"]
            },
            "ExportNamedDeclaration": {
                "enum": ["always", "never"]
            }

This would change the first option to be a default to those specific options. If they are not set, it will default to the first option.

There is a $10 open bounty on this issue. Add to the bounty at Bountysource.

@eslintbot
Copy link

Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Sep 12, 2015
@nzakas
Copy link
Member

nzakas commented Sep 14, 2015

Sounds good. Are you interested in working on this?

@nzakas nzakas added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Sep 14, 2015
@jonathanKingston
Copy link
Contributor Author

@nzakas already mostly complete 😃 will commit soon.

@nzakas nzakas added the help wanted The team would welcome a contribution from the community for this issue label Sep 26, 2015
@nzakas nzakas changed the title object-curly-spacing node type changes object-curly-spacing node type changes [$10] Sep 26, 2015
@nzakas nzakas added the bounty Someone has posted a bounty for this issue on BountySource label Sep 26, 2015
@gyandeeps
Copy link
Member

@jonathanKingston Are you still working on this (Just checking)?

@isnifer
Copy link

isnifer commented Jan 8, 2016

Hey @jonathanKingston I saw you did it. Do you plan to create PR for this feature?

@anyong
Copy link

anyong commented Mar 16, 2016

Any progress on this one?

@nzakas nzakas added the good first issue Good for people who haven't worked on ESLint before label Apr 21, 2016
@kaicataldo
Copy link
Member

kaicataldo commented Apr 25, 2016

I started in on this one - something I'm not sure of is what to do with the current exception options. From the rule docs:

These exceptions work in the context of the first option. That is, if "always" is set to enforce spacing and an exception is set to false, it will disallow spacing for cases matching the exception. Likewise, if "never" is set to disallow spacing and an exception is set to true, it will enforce spacing for cases matching the exception.

If we're specifying different values of "always" and "never", how should these options behave? We can't apply the same logic to each node type if they're set to different values (i.e. "objectsInObjects": false, would behave differently on the node types depending on their value). Does this mean we have to replicate the exception rules for each specific node type as well (although I guess not for ImportDeclarations)? Although obviously doable, the configuration for this rule might get a little crazy if we implement these changes.

I think the JSON Schema would like something like this (apologies if it's not quite right - still learning this stuff):

module.exports.schema = [
    {
        oneOf: [
            {
                {
                    enum: ["always", "never"]
                },
                {
                    type: "object",
                    properties: {
                        arraysInObjects: {
                            type: "boolean"
                        },
                        objectsInObjects: {
                            type: "boolean"
                        }
                    },
                    additionalProperties: false
                }
            },
            {
                type: "object",
                properties: {
                    ObjectPattern: {
                        enum: ["always", "never"],
                    {
                        type: "object",
                        properties: {
                            arraysInObjects: {
                                type: "boolean"
                            },
                            objectsInObjects: {
                                type: "boolean"
                            }
                        }
                        additionalProperties: false
                    },
                    ObjectExpression: {
                        enum: ["always", "never"], 
                        {
                            type: "object",
                            properties: {
                                arraysInObjects: {
                                    type: "boolean"
                                },
                                objectsInObjects: {
                                    type: "boolean"
                                }
                            },
                            additionalProperties: false
                        }
                    },
                    ImportDeclaration: {
                        enum: ["always", "never"]
                    },
                    ExportNamedDeclaration: {
                        enum: ["always", "never"],
                         {
                            type: "object",
                            properties: {
                                arraysInObjects: {
                                    type: "boolean"
                                },
                                objectsInObjects: {
                                    type: "boolean"
                                }
                            },
                            additionalProperties: false
                        }
                    }
                },
                additionalProperties: false
            }
        ]
    }
];

@gyandeeps
Copy link
Member

Is this issue resolved with #6223 ?
CC: @mysticatea

@mysticatea
Copy link
Member

No, I just referenced this issue from #6223.

@kaicataldo
Copy link
Member

In that case, thoughts on my last comment? Not sure where to go from here

@kaicataldo
Copy link
Member

Closing this issue as it has been open for more than 90 days and doesn't have anyone from the team or the community working on it.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 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 7, 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 bounty Someone has posted a bounty for this issue on BountySource enhancement This change enhances an existing feature of ESLint good first issue Good for people who haven't worked on ESLint before help wanted The team would welcome a contribution from the community for this issue rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

8 participants