@graphql-eslint/eslint-plugin 3.11.1-alpha-20220926113716-66ecd5e → 3.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +25 -17
  2. package/index.mjs +25 -17
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -86,22 +86,28 @@ const processor = {
86
86
  if (RELEVANT_KEYWORDS.every(keyword => !code.includes(keyword))) {
87
87
  return [code];
88
88
  }
89
- const extractedDocuments = graphqlTagPluck.parseCode({
90
- code,
91
- filePath,
92
- options: {
93
- skipIndent: true,
94
- ...graphQLTagPluckOptions,
95
- },
96
- });
97
- const blocks = extractedDocuments.map(item => ({
98
- filename: 'document.graphql',
99
- text: item.content,
100
- lineOffset: item.loc.start.line - 1,
101
- offset: item.start + 1,
102
- }));
103
- blocksMap.set(filePath, blocks);
104
- return [...blocks, code /* source code must be provided and be last */];
89
+ try {
90
+ const extractedDocuments = graphqlTagPluck.parseCode({
91
+ code,
92
+ filePath,
93
+ options: {
94
+ skipIndent: true,
95
+ ...graphQLTagPluckOptions,
96
+ },
97
+ });
98
+ const blocks = extractedDocuments.map(item => ({
99
+ filename: 'document.graphql',
100
+ text: item.content,
101
+ lineOffset: item.loc.start.line - 1,
102
+ offset: item.start + 1,
103
+ }));
104
+ blocksMap.set(filePath, blocks);
105
+ return [...blocks, code /* source code must be provided and be last */];
106
+ }
107
+ catch (_c) {
108
+ // in case of parsing error return code as is
109
+ return [code];
110
+ }
105
111
  },
106
112
  postprocess(messages, filePath) {
107
113
  const blocks = blocksMap.get(filePath) || [];
@@ -123,7 +129,9 @@ const processor = {
123
129
  }
124
130
  }
125
131
  }
126
- return messages.flat();
132
+ const result = messages.flat();
133
+ // sort eslint/graphql-eslint messages by line/column
134
+ return result.sort((a, b) => a.line - b.line || a.column - b.column);
127
135
  },
128
136
  };
129
137
 
package/index.mjs CHANGED
@@ -80,22 +80,28 @@ const processor = {
80
80
  if (RELEVANT_KEYWORDS.every(keyword => !code.includes(keyword))) {
81
81
  return [code];
82
82
  }
83
- const extractedDocuments = parseCode({
84
- code,
85
- filePath,
86
- options: {
87
- skipIndent: true,
88
- ...graphQLTagPluckOptions,
89
- },
90
- });
91
- const blocks = extractedDocuments.map(item => ({
92
- filename: 'document.graphql',
93
- text: item.content,
94
- lineOffset: item.loc.start.line - 1,
95
- offset: item.start + 1,
96
- }));
97
- blocksMap.set(filePath, blocks);
98
- return [...blocks, code /* source code must be provided and be last */];
83
+ try {
84
+ const extractedDocuments = parseCode({
85
+ code,
86
+ filePath,
87
+ options: {
88
+ skipIndent: true,
89
+ ...graphQLTagPluckOptions,
90
+ },
91
+ });
92
+ const blocks = extractedDocuments.map(item => ({
93
+ filename: 'document.graphql',
94
+ text: item.content,
95
+ lineOffset: item.loc.start.line - 1,
96
+ offset: item.start + 1,
97
+ }));
98
+ blocksMap.set(filePath, blocks);
99
+ return [...blocks, code /* source code must be provided and be last */];
100
+ }
101
+ catch (_c) {
102
+ // in case of parsing error return code as is
103
+ return [code];
104
+ }
99
105
  },
100
106
  postprocess(messages, filePath) {
101
107
  const blocks = blocksMap.get(filePath) || [];
@@ -117,7 +123,9 @@ const processor = {
117
123
  }
118
124
  }
119
125
  }
120
- return messages.flat();
126
+ const result = messages.flat();
127
+ // sort eslint/graphql-eslint messages by line/column
128
+ return result.sort((a, b) => a.line - b.line || a.column - b.column);
121
129
  },
122
130
  };
123
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.11.1-alpha-20220926113716-66ecd5e",
3
+ "version": "3.11.1",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {