match-document-filename
Since 0.9.0 · In the rulesets: All at error
This rule checks that the file name of a document with one operation or fragment is the name of the definition.
Rule details
Files named after their operation are easy to find. Documents with several definitions are not checked (see lone-executable-definition).
The rule applies to operations and fragments. An # apigenie-lint-disable match-document-filename
comment on a node turns it off for the node and everything nested in it; at the top of the file,
separated from the first definition by a blank line, the comment turns it off for the whole file.
Configuration
The configuration block is an object with the properties:
style: the case of the file name,camelCase,camelCaseStrict,PascalCase,PascalCaseStrict,snake_case,CONST_CASE(orUPPER_CASE),kebab-caseorHeader-Case; the strict forms reject two capitals in a row (userID); the name as written by defaultfileExtension: the extension the file must have, e.g..gql; any by default
version: "1.0"
commands:
lint:
graphql:
rules:
match-document-filename: [error, { style: kebab-case, fileExtension: .graphql }]
Examples
Good.
# GetUser.graphql
query GetUser { me { id } }
Bad. The linter reports The file name 'user.graphql' should match the query 'GetUser', e.g. 'GetUser.graphql'.
# user.graphql
query GetUser { me { id } }
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.graphql has the details.
commands:
lint:
graphql:
rules:
match-document-filename: off