strk-linter
v1.0.0
Published
Custom ESLint rules for Sitetracker development standards and best practices
Downloads
4
Maintainers
Readme
strk-linter
Custom ESLint rules for Sitetracker development standards and best practices.
Quick Setup
1. Install the plugin
npm install --save-dev strk-linter2. Update your ESLint configuration
For Lightning Web Components (most common):
Edit your .eslintrc.json file in your LWC directory (e.g., force-app/main/default/lwc/.eslintrc.json):
{
"extends": ["@salesforce/eslint-config-lwc/recommended"],
"plugins": ["strk"],
"rules": {
"strk/early-exit": "error",
"strk/no-label-literal": "error",
"strk/no-async-connectedcallback": "error",
"strk/no-empty-object-init": "error",
"strk/require-mocks-import": "error",
"strk/require-apex-mocks-centralization": "error",
"strk/no-component-mock-in-tests": "error",
"strk/require-leading-comment-for-jest": "error"
},
"overrides": [
{
"files": ["*.test.js"],
"rules": {
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
},
"env": {
"node": true
}
}
]
}3. Verify it's working
Run ESLint on a file to confirm the rules are active:
npx eslint your-file.jsYou should see Sitetracker-specific linting errors if any of the rules are violated.
VS Code Setup (Red Squiggles)
To see ESLint errors as red squiggles in VS Code:
Required Extensions
- ESLint (
dbaeumer.vscode-eslint) - Shows linting errors in real-time - Salesforce Extension Pack (
salesforce.salesforcedx-vscode) - For LWC support
Setup Steps
- Install extensions from VS Code marketplace
- Install the plugin (step 1 above)
- Restart VS Code
- Test with sample code:
// This should show red squiggles:
const obj = {}; // Violates strk/no-empty-object-init
// This should also show red squiggles:
if (someCondition) {
doSomething();
}
// No else or early return - violates strk/early-exitVerification
- Red squiggles should appear under violating code
- Problems panel (
Cmd+Shift+M) shows Sitetracker-specific errors - Auto-fix on save available for some rules
VS Code Troubleshooting
No red squiggles?
- Check "ESLint: Show Output Channel" in Command Palette
- Reload VS Code window: "Developer: Reload Window"
- Verify file paths match:
src/main/default/lwc/or2gp-packages/*/force-app/main/default/lwc/
Configuration Notes
- Rule severity: All rules are set to
"error"by default. You can change them to"warn"if preferred. - Selective rules: You can enable only specific rules by removing unwanted ones from the
rulessection. - Rule documentation: Each rule links to our Development Standards when violated.
Troubleshooting
"Plugin not found" error?
- Ensure you've installed the plugin:
npm install --save-dev strk-linter
Rules not working?
- Check your ESLint config syntax with:
npx eslint --print-config your-file.js - Ensure your files match the patterns ESLint is checking
Updates
When new versions are released, update with:
npm update strk-linterFor detailed information about Sitetracker development standards: Development and Test Standards
