-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
import createRule from '../../util/createRule'; | ||
|
||
export default createRule({ | ||
create(context) { | ||
return { | ||
ImportDeclaration(node) { | ||
if (node.source.value.startsWith('@salesforce/apex')) { | ||
context.report({ | ||
node, | ||
messageId: 'message' | ||
}); | ||
} | ||
} | ||
}; | ||
}, | ||
name: 'apex-import', | ||
meta: { | ||
docs: { | ||
description: 'Importing apex modules can have issues on mobile for offline usage.' | ||
}, | ||
messages: { | ||
message: 'Importing apex modules can have issues on mobile for offline usage.' | ||
}, | ||
type: 'suggestion', | ||
schema: [] | ||
}, | ||
defaultOptions: [] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
import { ESLintUtils } from '@typescript-eslint/utils'; | ||
|
||
export default ESLintUtils.RuleCreator( | ||
// TODO: Add path to the doc like it is done here when the docs are ready | ||
// https://github.com/salesforce/eslint-plugin-lwc-graph-analyzer/blob/main/lib/util/doc-url.js | ||
(_name) => `` | ||
Check failure on line 13 in src/util/createRule.ts
|
||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
import { RuleTester } from '@typescript-eslint/rule-tester'; | ||
|
||
import apexImport from '../../../src/rules/apex/apex-import'; | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: '@typescript-eslint/parser' | ||
}); | ||
|
||
ruleTester.run('@salesforce/lwc-mobile/apex/apex-import', apexImport, { | ||
valid: [], | ||
invalid: [ | ||
{ | ||
code: ` | ||
import { LightningElement, wire } from 'lwc'; | ||
import getContactList from '@salesforce/apex/ContactController.getContactList'; | ||
export default class ApexWireMethodToFunction extends LightningElement { | ||
contacts; | ||
error; | ||
@wire(getContactList) | ||
wiredContacts({ error, data }) { | ||
if (data) { | ||
this.contacts = data; | ||
this.error = undefined; | ||
} else if (error) { | ||
this.error = error; | ||
this.contacts = undefined; | ||
} | ||
} | ||
} | ||
`, | ||
errors: [{ messageId: 'message' }] | ||
} | ||
] | ||
}); |