Skip to content

Commit

Permalink
add document
Browse files Browse the repository at this point in the history
  • Loading branch information
haifeng-li-at-salesforce committed May 24, 2024
1 parent 7e712c4 commit ee48a6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export = {
skipGraphQLConfig: true
},
rules: {
[createScopedModuleRuleName(NO_MUTATION_SUPPORTED_RULE_ID)]: 'warn',
[createScopedModuleRuleName(NO_AGGREGATE_QUERY_SUPPORTED_RULE_ID)]: 'warn',
[createScopedModuleRuleName(UNSUPPORTED_SCOPE_RULE_ID)]: 'warn',
[createScopedModuleRuleName(NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID)]: 'warn',
[createScopedModuleRuleName(NO_MUTATION_SUPPORTED_RULE_ID)]: 'warn',
[createScopedModuleRuleName(NO_SEMI_ANTI_JOIN_SUPPORTED_RULE_ID)]: 'warn',
[createScopedModuleRuleName(NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID)]: 'warn'
[createScopedModuleRuleName(UNSUPPORTED_SCOPE_RULE_ID)]: 'warn'
}
}
]
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import {
rule as fiscalDataFilteringNotSupported
} from './rules/graphql/no-fiscal-date-filtering-supported.js';

import {
NO_SEMI_ANTI_JOIN_SUPPORTED_RULE_ID,
rule as semiantiJoinNotSupported
} from './rules/graphql/no-semi-anti-join-supported.js';

import { name, version } from '../package.json';

export = {
Expand All @@ -44,8 +49,9 @@ export = {
'enforce-foo-bar': enforceFooBar,
[APEX_IMPORT_RULE_ID]: apexImport,
[NO_AGGREGATE_QUERY_SUPPORTED_RULE_ID]: aggregateQueryNotSupported,
[NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID]: fiscalDataFilteringNotSupported,
[NO_MUTATION_SUPPORTED_RULE_ID]: mutationNotSupported,
[UNSUPPORTED_SCOPE_RULE_ID]: unsupportedScope,
[NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID]: fiscalDataFilteringNotSupported
[NO_SEMI_ANTI_JOIN_SUPPORTED_RULE_ID]: semiantiJoinNotSupported,
[UNSUPPORTED_SCOPE_RULE_ID]: unsupportedScope
}
};
9 changes: 5 additions & 4 deletions src/rules/graphql/no-fiscal-date-filtering-supported.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Kind } from 'graphql';
import { GraphQLESLintRule, GraphQLESLintRuleContext } from '@graphql-eslint/eslint-plugin';

import getDocUrl from '../../util/getDocUrl';
export const NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID =
'offline-graphql-no-fiscal-date-filter-supported';

Expand All @@ -16,6 +16,7 @@ export const rule: GraphQLESLintRule = {
docs: {
description: 'fiscal date literals/ranges are not supported offline',
category: 'Operations',
url: getDocUrl(NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID),
recommended: true,
examples: [
{
Expand Down Expand Up @@ -100,7 +101,7 @@ export const rule: GraphQLESLintRule = {
return {
ObjectField(node) {
if (node.kind == Kind.OBJECT_FIELD && node.name.kind === Kind.NAME) {
// Example: {literal : LAST_FISCAL_YEAR}.
// Example: where : {LastAcitivtyDate: {eq: {literal : LAST_FISCAL_YEAR }}}.
if (
node.name.value === 'literal' &&
node.value.kind === Kind.ENUM &&
Expand All @@ -110,7 +111,7 @@ export const rule: GraphQLESLintRule = {
{
context.report({
messageId: NO_FISCAL_DATE_FILTER_SUPPORTED_RULE_ID,
node,
node: node.value,
data: {
filterType: 'literal',
filterName: node.value.value
Expand All @@ -122,7 +123,7 @@ export const rule: GraphQLESLintRule = {
node.value.kind === Kind.OBJECT &&
node.value.fields.length > 0
) {
// Example: {range: {LAST_N_FISCAL_YEARS: 1}}.
// Example: where : {LastAcitivtyDate: {eq: {range: {LAST_N_FISCAL_YEARS: 1 }}}}.
const rangeObjectField = node.value.fields[0];
// Checks if it is a fiscal date filter, for example 'LAST_N_FISCAL_QUATERS', 'N_FISCAL_YEARS_AGO'.
if (rangeObjectField.name.value.toLowerCase().indexOf('fiscal')) {
Expand Down

0 comments on commit ee48a6f

Please sign in to comment.