Skip to content

Commit 1729313

Browse files
authored
feat: add autofix for alphabetize rule and change sort order to lexicographic (#936)
* feat: add autofix for `alphabetize` rule * feat: improve rule-tester * feat: skip autofix for fields with comments between or around * should compare with lexicographic order * add info about autofix in generate-docs script * update examples deps to trigger patches folder changes * fix build * fix test on node 12 * add autofix even for fields with comments * fix ESTree parser, convert `loc.column` to 0-based column number (#939) * fixes after rebase * fixes tests on graphql 15
1 parent d9bdbd3 commit 1729313

File tree

77 files changed

+1253
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1253
-625
lines changed

.changeset/great-fans-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
fix ESTree parser, convert `loc.column` to 0-based column number

.changeset/silver-worms-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': minor
3+
---
4+
5+
feat: add autofix for `alphabetize` rule and change sort order to lexicographic

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
reportUnusedDisableDirectives: true,
33
ignorePatterns: ['examples'],
44
parser: '@typescript-eslint/parser',
5-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'standard', 'prettier'],
5+
extends: ['eslint:recommended', 'standard', 'plugin:@typescript-eslint/recommended', 'prettier'],
66
plugins: ['unicorn'],
77
rules: {
88
'no-empty': 'off',

docs/parser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Here's a list of changes that the parser performs, in order to make the GraphQL
3636

3737
**Problem**: GraphQL uses `location` field to store the AST locations, while ESTree also uses it in a different structure.
3838

39-
**Solution**: The parser creates a new `location` field that is compatible with ESTree, and renames the GraphQL `location` to `gqlLocation`.
39+
**Solution**: The parser creates a new `location` field that is compatible with ESTree.
4040

4141
### Loading GraphQL Schema
4242

docs/rules/alphabetize.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# `alphabetize`
22

3+
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
4+
35
- Category: `Schema & Operations`
46
- Rule name: `@graphql-eslint/alphabetize`
57
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "3.7.0",
16-
"eslint": "8.2.0"
16+
"eslint": "8.7.0"
1717
}
1818
}

examples/code-file/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "3.7.0",
16-
"eslint": "8.2.0"
16+
"eslint": "8.7.0"
1717
}
1818
}

examples/graphql-config-code-file/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
},
1515
"devDependencies": {
1616
"@graphql-eslint/eslint-plugin": "3.7.0",
17-
"eslint": "8.2.0"
17+
"eslint": "8.7.0"
1818
}
1919
}

examples/graphql-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "3.7.0",
16-
"eslint": "8.2.0"
16+
"eslint": "8.7.0"
1717
}
1818
}

examples/prettier/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "3.7.0",
16-
"eslint": "8.2.0",
16+
"eslint": "8.7.0",
1717
"eslint-config-prettier": "8.3.0",
1818
"eslint-plugin-prettier": "4.0.0",
1919
"prettier": "2.4.1"

0 commit comments

Comments
 (0)