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

Add nexus-upper-case-enum-members rule #318

Merged
merged 5 commits into from
Jan 27, 2020

Conversation

yamadayuki
Copy link
Collaborator

WHY & WHAT

Check the enum members are UPPER_CASE if the code using nexus (wantedly/nexus-upper-case-enum-members)

Rule Details

Valid

import { enumType } from "nexus";
// Array literal
const Episode = enumType({
  name: "Episode",
  members: ["NEW_HOPE", "EMPIRE", "JEDI"],
});
// Object literal
const Episode = enumType({
  name: "Episode",
  members: { NEW_HOPE: 1, EMPIRE: 2, JEDI: 3 },
});

Invalid

import { enumType } from "nexus";
// Array literal
const Episode = enumType({
  name: "Episode",
  members: ["newHope", "empire", "jedi"],
});
// Object literal
const Episode = enumType({
  name: "Episode",
  members: { newHope: 1, empire: 2, jedi: 3 },
});

This rule is automatically fix some problems reported by this rule if the autofix option is true.

Options

autofix

The autofix option is enabling the auto fix function.

{
  "rule": {
    "wantedly/nexus-upper-case-enum-members": ["error", { "autofix": true }]
  }
}
/* eslint wantedly/nexus-upper-case-enum-members: ["error", { "autofix": true }] */

@yamadayuki yamadayuki added the enhancement New feature or request label Jan 27, 2020
@yamadayuki yamadayuki merged commit 629b179 into master Jan 27, 2020
@yamadayuki yamadayuki deleted the yamadayuki/nexus-upper-case-enum-members branch January 27, 2020 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant