@graphql-eslint/eslint-plugin 3.11.0-alpha-20220822143702-ea4e67a → 3.11.0-alpha-20220828135635-ce6bf36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -705,6 +705,14 @@ const rule = {
705
705
  description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
706
706
  default: false,
707
707
  },
708
+ ignorePrefix: {
709
+ type: 'array',
710
+ default: [],
711
+ },
712
+ ignoreSuffix: {
713
+ type: 'array',
714
+ default: [],
715
+ },
708
716
  },
709
717
  },
710
718
  },
@@ -759,6 +767,18 @@ const rule = {
759
767
  const prevNode = nodes[i - 1];
760
768
  const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) || ('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
761
769
  if (prevName) {
770
+ if ((opts.ignorePrefix || []).length > 0) {
771
+ const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName || prefix === currName || prevName.startsWith(prefix) || currName.startsWith(prefix));
772
+ if (shouldSkipIgnorePrefix) {
773
+ continue;
774
+ }
775
+ }
776
+ if ((opts.ignoreSuffix || []).length > 0) {
777
+ const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName || suffix === currName || prevName.endsWith(suffix) || currName.endsWith(suffix));
778
+ if (shouldSkipIgnoreSuffix) {
779
+ continue;
780
+ }
781
+ }
762
782
  // Compare with lexicographic order
763
783
  const compareResult = prevName.localeCompare(currName);
764
784
  const shouldSort = compareResult === 1;
@@ -1128,32 +1148,6 @@ const rule$3 = {
1128
1148
  fullName
1129
1149
  }
1130
1150
  }
1131
- `,
1132
- },
1133
- {
1134
- title: 'Correct',
1135
- usage: [{ fragment: { style: 'kebab-case', suffix: 'Mutation', prefix: 'mutation.' } }],
1136
- name: 'mutation.add-alert.graphql',
1137
- code: /* GraphQL */ `
1138
- # mutation.add-alert.graphql
1139
- mutation addAlert($input: AddAlertInput!) {
1140
- addAlert(input: $input) {
1141
- ...AlertFields
1142
- }
1143
- }
1144
- `,
1145
- },
1146
- {
1147
- title: 'Correct',
1148
- usage: [{ fragment: { prefix: 'query.' } }],
1149
- name: 'query.me.graphql',
1150
- code: /* GraphQL */ `
1151
- # query.me.graphql
1152
- query me {
1153
- me {
1154
- ...UserFields
1155
- }
1156
- }
1157
1151
  `,
1158
1152
  },
1159
1153
  ],
@@ -1183,7 +1177,6 @@ const rule$3 = {
1183
1177
  properties: {
1184
1178
  style: { enum: CASE_STYLES },
1185
1179
  suffix: { type: 'string' },
1186
- prefix: { type: 'string' },
1187
1180
  },
1188
1181
  },
1189
1182
  },
@@ -1249,12 +1242,12 @@ const rule$3 = {
1249
1242
  option = { style: option };
1250
1243
  }
1251
1244
  const expectedExtension = options.fileExtension || fileExtension;
1252
- let expectedFilename = option.prefix || '';
1245
+ let expectedFilename;
1253
1246
  if (option.style) {
1254
- expectedFilename += option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
1247
+ expectedFilename = option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
1255
1248
  }
1256
1249
  else {
1257
- expectedFilename += filename;
1250
+ expectedFilename = filename;
1258
1251
  }
1259
1252
  expectedFilename += (option.suffix || '') + expectedExtension;
1260
1253
  const filenameWithExtension = filename + expectedExtension;
package/index.mjs CHANGED
@@ -699,6 +699,14 @@ const rule = {
699
699
  description: 'Definitions – `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`.',
700
700
  default: false,
701
701
  },
702
+ ignorePrefix: {
703
+ type: 'array',
704
+ default: [],
705
+ },
706
+ ignoreSuffix: {
707
+ type: 'array',
708
+ default: [],
709
+ },
702
710
  },
703
711
  },
704
712
  },
@@ -753,6 +761,18 @@ const rule = {
753
761
  const prevNode = nodes[i - 1];
754
762
  const prevName = ('alias' in prevNode && ((_c = prevNode.alias) === null || _c === void 0 ? void 0 : _c.value)) || ('name' in prevNode && ((_d = prevNode.name) === null || _d === void 0 ? void 0 : _d.value));
755
763
  if (prevName) {
764
+ if ((opts.ignorePrefix || []).length > 0) {
765
+ const shouldSkipIgnorePrefix = opts.ignorePrefix.some(prefix => prefix === prevName || prefix === currName || prevName.startsWith(prefix) || currName.startsWith(prefix));
766
+ if (shouldSkipIgnorePrefix) {
767
+ continue;
768
+ }
769
+ }
770
+ if ((opts.ignoreSuffix || []).length > 0) {
771
+ const shouldSkipIgnoreSuffix = opts.ignoreSuffix.some(suffix => suffix === prevName || suffix === currName || prevName.endsWith(suffix) || currName.endsWith(suffix));
772
+ if (shouldSkipIgnoreSuffix) {
773
+ continue;
774
+ }
775
+ }
756
776
  // Compare with lexicographic order
757
777
  const compareResult = prevName.localeCompare(currName);
758
778
  const shouldSort = compareResult === 1;
@@ -1122,32 +1142,6 @@ const rule$3 = {
1122
1142
  fullName
1123
1143
  }
1124
1144
  }
1125
- `,
1126
- },
1127
- {
1128
- title: 'Correct',
1129
- usage: [{ fragment: { style: 'kebab-case', suffix: 'Mutation', prefix: 'mutation.' } }],
1130
- name: 'mutation.add-alert.graphql',
1131
- code: /* GraphQL */ `
1132
- # mutation.add-alert.graphql
1133
- mutation addAlert($input: AddAlertInput!) {
1134
- addAlert(input: $input) {
1135
- ...AlertFields
1136
- }
1137
- }
1138
- `,
1139
- },
1140
- {
1141
- title: 'Correct',
1142
- usage: [{ fragment: { prefix: 'query.' } }],
1143
- name: 'query.me.graphql',
1144
- code: /* GraphQL */ `
1145
- # query.me.graphql
1146
- query me {
1147
- me {
1148
- ...UserFields
1149
- }
1150
- }
1151
1145
  `,
1152
1146
  },
1153
1147
  ],
@@ -1177,7 +1171,6 @@ const rule$3 = {
1177
1171
  properties: {
1178
1172
  style: { enum: CASE_STYLES },
1179
1173
  suffix: { type: 'string' },
1180
- prefix: { type: 'string' },
1181
1174
  },
1182
1175
  },
1183
1176
  },
@@ -1243,12 +1236,12 @@ const rule$3 = {
1243
1236
  option = { style: option };
1244
1237
  }
1245
1238
  const expectedExtension = options.fileExtension || fileExtension;
1246
- let expectedFilename = option.prefix || '';
1239
+ let expectedFilename;
1247
1240
  if (option.style) {
1248
- expectedFilename += option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
1241
+ expectedFilename = option.style === 'matchDocumentStyle' ? docName : convertCase(option.style, docName);
1249
1242
  }
1250
1243
  else {
1251
- expectedFilename += filename;
1244
+ expectedFilename = filename;
1252
1245
  }
1253
1246
  expectedFilename += (option.suffix || '') + expectedExtension;
1254
1247
  const filenameWithExtension = filename + expectedExtension;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.11.0-alpha-20220822143702-ea4e67a",
3
+ "version": "3.11.0-alpha-20220828135635-ce6bf36",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -11,6 +11,8 @@ export declare type AlphabetizeConfig = {
11
11
  variables?: typeof variablesEnum;
12
12
  arguments?: typeof argumentsEnum;
13
13
  definitions?: boolean;
14
+ ignorePrefix?: string[];
15
+ ignoreSuffix?: string[];
14
16
  };
15
17
  declare const rule: GraphQLESLintRule<[AlphabetizeConfig]>;
16
18
  export default rule;
@@ -5,7 +5,6 @@ declare const ACCEPTED_EXTENSIONS: ['.gql', '.graphql'];
5
5
  declare type PropertySchema = {
6
6
  style?: CaseStyle;
7
7
  suffix?: string;
8
- prefix?: string;
9
8
  };
10
9
  export declare type MatchDocumentFilenameRuleConfig = {
11
10
  fileExtension?: typeof ACCEPTED_EXTENSIONS[number];