diff --git a/jest.config.ts b/jest.config.ts index 895dd9f..d9490c2 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -14,7 +14,7 @@ const config: Config = { testMatch: ['/test/**/*.ts'], moduleFileExtensions: ['ts', 'js', 'json'], testResultsProcessor: 'jest-sonar-reporter', - testPathIgnorePatterns: ['/node_modules/', '/lib/'], + testPathIgnorePatterns: ['/node_modules/', '/lib/', '/test/shared.ts'], moduleDirectories: ['node_modules'], collectCoverage: true, collectCoverageFrom: ['src/**/*.ts', '!src/index.ts', '!src/configs/*.ts'], diff --git a/src/configs/recommended.ts b/src/configs/recommended.ts index 68769b3..f9f3867 100644 --- a/src/configs/recommended.ts +++ b/src/configs/recommended.ts @@ -24,8 +24,8 @@ export = { skipGraphQLConfig: true }, rules: { - '@salesforce/lwc-mobile/offline-graphql-no-mutation-supported': 'warn', '@salesforce/lwc-mobile/offline-graphql-no-aggregate-query-supported': 'warn', + '@salesforce/lwc-mobile/offline-graphql-no-mutation-supported': 'warn', '@salesforce/lwc-mobile/offline-graphql-unsupported-scope': 'warn' } } diff --git a/src/index.ts b/src/index.ts index 273e76c..967fbb1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,13 +18,14 @@ import { NO_MUTATION_SUPPORTED_RULE_ID, rule as mutationNotSupported } from './rules/graphql/no-mutation-supported.js'; -import { name, version } from '../package.json'; import { - rule as offlineGraphqlUnsupportedScope, - UNSUPPORTED_SCOPE_RULE_ID + UNSUPPORTED_SCOPE_RULE_ID, + rule as unsupportedScope } from './rules/graphql/unsupported-scope.js'; +import { name, version } from '../package.json'; + export = { configs: { base, @@ -38,7 +39,7 @@ export = { 'enforce-foo-bar': enforceFooBar, [APEX_IMPORT_RULE_ID]: apexImport, [NO_AGGREGATE_QUERY_SUPPORTED_RULE_ID]: aggregateQueryNotSupported, - [NO_MUTATION_SUPPORTED_RULE_ID]: mutionNotSupported, - [UNSUPPORTED_SCOPE_RULE_ID]: offlineGraphqlUnsupportedScope + [NO_MUTATION_SUPPORTED_RULE_ID]: mutationNotSupported, + [UNSUPPORTED_SCOPE_RULE_ID]: unsupportedScope } }; diff --git a/src/rules/graphql/unsupported-scope.ts b/src/rules/graphql/unsupported-scope.ts index d74e0c3..4fd34a4 100644 --- a/src/rules/graphql/unsupported-scope.ts +++ b/src/rules/graphql/unsupported-scope.ts @@ -6,6 +6,8 @@ export const UNSUPPORTED_SCOPE_RULE_ID = 'offline-graphql-unsupported-scope'; export const SCOPE_SUPPORTED_FOR_CERTAIN_ENTITIES_ONLY = 'ASSIGNED_TO_ME__SERVICEAPPOINTMENT_ONLY'; export const OTHER_UNSUPPORTED_SCOPE = 'OTHER_UNSUPPORTED_SCOPE'; +import getDocUrl from '../../util/getDocUrl'; + // key is scope name, value is the array of supported entities. Empty array means that all entities are supported. const supportedScopes: Record = { MINE: [], @@ -15,8 +17,9 @@ export const rule: GraphQLESLintRule = { meta: { type: 'problem', docs: { - description: `For mobile offline use cases, scope "MINE" is supported and scope "ASSIGNEDTOME" is only supported for ServiceAppointment . All other scopes like TEAM, QUEUE_OWNED and USER_OWNED are not supported `, category: 'Operations', + description: `For mobile offline use cases, scope "MINE" is supported and scope "ASSIGNEDTOME" is only supported for ServiceAppointment . All other scopes like TEAM, QUEUE_OWNED and USER_OWNED are not supported `, + url: getDocUrl(UNSUPPORTED_SCOPE_RULE_ID), recommended: true, examples: [ { diff --git a/test/rules/graphql/no-aggregate-query-supported.spec.ts b/test/rules/graphql/no-aggregate-query-supported.spec.ts index a034b7e..43bf7bf 100644 --- a/test/rules/graphql/no-aggregate-query-supported.spec.ts +++ b/test/rules/graphql/no-aggregate-query-supported.spec.ts @@ -4,12 +4,9 @@ import { NO_AGGREGATE_QUERY_SUPPORTED_RULE_ID } from '../../../src/rules/graphql/no-aggregate-query-supported'; -const ruleTester = new RuleTester({ - parser: '@graphql-eslint/eslint-plugin', - parserOptions: { - graphQLConfig: {} - } -}); +import { RULE_TESTER_CONFIG } from '../../shared'; + +const ruleTester = new RuleTester(RULE_TESTER_CONFIG); ruleTester.run('@salesforce/lwc-mobile/no-aggregate-query-supported', rule as any, { valid: [