Code Monkey home page Code Monkey logo

eslint-plugin-graphql-schema's Introduction

eslint-plugin-graphql-schema

An ESLint plugin to validate GraphQL schema definitions against a set of rules.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-graphql-schema:

npm install eslint-plugin-graphql-schema --save-dev

To use you must include the graphql or gql extensions

eslint --ext .graphql

Plugging it in

Add graphql-schema to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "graphql-schema"
    ]
}

Overriding and settings rules

Configure the rules you want to use under the rules section. We do recommend that you only use file patterns that include *Schema* and/or *schema* as this is the pattern found in Shared Configurations.

{
    "overrides":[
        {
            "files": ["*schema*.graphql", "*Schema*.graphql", "*schema*.gql", "*Schema*.gql"],
            "parser": "eslint-plugin-graphql-schema/parser",
            "rules": {
               "graphql-schema/arguments-have-descriptions": ["off", {"commentDescriptions": false}],
               "graphql-schema/type-fields-have-descriptions": ["warn", {"commentDescriptions": false}],
               "graphql-schema/types-have-descriptions": ["off", {"commentDescriptions": false}],
               "graphql-schema/type-fields-have-trailing-commas": ["error", "never"],
               "graphql-schema/object-types-have-prefixes": ["error", {"prefixes": ["Org"]}]
            }
        }
    ]
}

Rules

Shared Configurations

Recommended

This is a good mix of warnings and errors.

{
    "extends": [
        "plugin:graphql-schema/recommended"
   ]
}

Mom

This is all about explaining yourself and giving everything a description. Don't worry! It's only a stern warning.

{
    "extends": [
        "plugin:graphql-schema/mom"
   ]
}

Hero

All rules get enabled and stand ready to error. Be the hero your team deserves!

{
    "extends": [
        "plugin:graphql-schema/hero"
   ]
}

Contributing

Credit

License

eslint-plugin-graphql-schema is licensed under the MIT License.

eslint-plugin-graphql-schema's People

Contributors

joshuanathaniel avatar dependabot[bot] avatar

Stargazers

Curtis M. Humphrey, Ph.D. avatar Joshua N Miller avatar  avatar

Watchers

James Cloos avatar  avatar

eslint-plugin-graphql-schema's Issues

Add fixers for rules

Currently --fix only works for trailing commas. I would like to every rule have a fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.