Skip to content

Commit

Permalink
no-more-than-2-fields works with eslintrc
Browse files Browse the repository at this point in the history
  • Loading branch information
haifeng-li-at-salesforce committed May 13, 2024
1 parent 8447af3 commit de97ab0
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 7 deletions.
26 changes: 21 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/stylistic"
"extends": ["eslint:recommended", "plugin:@salesforce/lwc-mobile/recommended"],

"plugins": ["@salesforce/lwc-mobile", "@graphql-eslint"],
"overrides": [
{
"files": ["graphqlBatchTest.js"],
"processor": "@graphql-eslint/graphql"
},
{
"files": ["*.graphql"],
"parser": "@graphql-eslint/eslint-plugin",

"parserOptions": {
"skipGraphQLConfig": true
},
"rules": {
"@salesforce/lwc-mobile/enforce-foo-bar": "warn",
"@salesforce/lwc-mobile/no-more-than-2-fields": "warn"
}
}
],
"env": {
"jest": true,
Expand All @@ -13,4 +29,4 @@
"strict": ["error", "global"]
},
"ignorePatterns": ["test/**/test.js"]
}
}
67 changes: 67 additions & 0 deletions graphqlBatchTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { LightningElement, wire, track, api } from 'lwc';
import { gql, graphql } from 'lightning/uiGraphQLApi';

const foo = 'abcd';
export default class graphqlBatchTest extends LightningElement {
@api
recordId;

@track
results;
@track
errors;

@wire(graphql, {
query: '$caseQuery',
variables: '$variables'
})
runGraphql({ data, errors }) {
if (data) {
this.results = JSON.stringify(data);
this.errors = undefined;
} else {
this.errors = JSON.stringify(errors);

this.results = undefined;
}
}

get caseQuery() {
return gql`
query getCases($recordId: ID) {
uiapi {
query {
Case(
where: {
and: [{ AccountId: { eq: $recordId } }, { Status: { eq: "New" } }]
}
first: 2
) {
edges {
node {
Id
Subject {
value
}
Name {
value
}
Name {
value
}
AccountId {
value
}
}
}
}
}
}
}
`;
}

get variables() {
return { recordId: this.recordId };
}
}
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"format": "prettier --list-different \"**/*.{ts,js}\"",
"format:fix": "prettier --write \"**/*.{ts,js,json}\"",
"lint": "eslint src test",
"test": "jest --coverage"
"test": "jest --coverage",
"cppackage": "cp package.json node_modules/@salesforce/eslint-plugin-lwc-mobile"
},
"jestSonar": {
"sonar56x": true,
Expand Down Expand Up @@ -79,7 +80,8 @@
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.8.0"
"typescript-eslint": "^7.8.0",
"@salesforce/eslint-plugin-lwc-mobile": "file:dist"
},
"peerDependencies": {
"eslint": ">=7"
Expand Down
11 changes: 11 additions & 0 deletions testQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const foo = 'bar';

const q = gql`
query {
user {
name
email
name
}
}
`;

0 comments on commit de97ab0

Please sign in to comment.