@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.
- package/index.js +25 -17
- package/index.mjs +25 -17
- 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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
-
|
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
|
|