Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/reports
test-report.xml
junit.xml

.DS_Store
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,32 @@ ESLint version-specific configuration examples are provided below. Here are some

The default configurations are now in the flat config format supported by ESLint 9 and beyond. Here's how to include the `recommended` config in your flat config:

```javascript
// eslint.config.js
const { defineConfig } = require("eslint/config");
const lwcGraphAnalyzerPlugin = require("@salesforce/eslint-plugin-lwc-graph-analyzer");

module.exports = defineConfig([
{
plugins: {
"@salesforce/lwc-graph-analyzer": lwcGraphAnalyzerPlugin,
},
extends: [lwcGraphAnalyzerPlugin.configs.recommended],
},
]);
```

```javascript
// eslint.config.mjs
import js from '@eslint/js';
import lwcGraphAnalyzerPlugin from '@salesforce/eslint-plugin-lwc-graph-analyzer';

export default [
{ plugins: { '@salesforce/lwc-graph-analyzer': lwcGraphAnalyzerPlugin } },
{
plugins: {
'@salesforce/lwc-graph-analyzer': lwcGraphAnalyzerPlugin
}
},
js.configs.recommended,
lwcGraphAnalyzerPlugin.configs.recommended
];
Expand Down
186 changes: 93 additions & 93 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
{
"name": "@salesforce/eslint-plugin-lwc-graph-analyzer",
"version": "1.0.0",
"description": "ESLint plugin to analyze data graph in a LWC component",
"contributors": [
{
"name": "Andrew Huffman",
"url": "https://github.com/AndrewHuffman"
"name": "@salesforce/eslint-plugin-lwc-graph-analyzer",
"version": "1.1.0",
"description": "ESLint plugin to analyze data graph in a LWC component",
"contributors": [
{
"name": "Andrew Huffman",
"url": "https://github.com/AndrewHuffman"
},
{
"name": "Kevin Hawkins",
"url": "https://github.com/khawkins"
},
{
"name": "Meisam Seyed Aliroteh",
"url": "https://github.com/maliroteh-sf"
},
{
"name": "Takashi Arai",
"url": "https://github.com/sfdctaka"
},
{
"name": "Dustin Breese",
"url": "https://github.com/dbreese"
}
],
"homepage": "https://github.com/salesforce/eslint-plugin-lwc-graph-analyzer",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/salesforce/eslint-plugin-lwc-graph-analyzer.git"
},
{
"name": "Kevin Hawkins",
"url": "https://github.com/khawkins"
"main": "lib/index.js",
"types": "lib/index.d.ts",
"directories": {
"lib": "lib",
"rules": "lib/rules",
"test": "test"
},
{
"name": "Meisam Seyed Aliroteh",
"url": "https://github.com/maliroteh-sf"
"files": [
"lib/**/*",
"!**/test/**"
],
"devDependencies": {
"@eslint/js": "^9.30.1",
"@typescript-eslint/parser": "^8.35.1",
"chai": "^4.5.0",
"eslint": "^9.28.0",
"eslint-plugin-eslint-plugin": "^6.5.0",
"eslint-plugin-n": "^17.20.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-chain": "^1.1.6",
"jest-extended": "^4.0.2",
"jest-junit": "^16.0.0",
"jest-sonar-reporter": "^2.0.0",
"prettier": "^3.6.2",
"typescript": "^5.8.3",
"typescript-eslint": "^8.35.1"
},
{
"name": "Takashi Arai",
"url": "https://github.com/sfdctaka"
"dependencies": {
"@babel/core": "^7.28.0",
"@babel/eslint-parser": "^7.28.0",
"@komaci/static-analyzer": "^260.31.0",
"@lwc/errors": "^8.21.1",
"@lwc/metadata": "^12.0.0",
"@lwc/sfdc-compiler-utils": "^12.0.0",
"@lwc/template-compiler": "^8.21.1",
"@types/eslint": "^9.6.1"
},
{
"name": "Dustin Breese",
"url": "https://github.com/dbreese"
"scripts": {
"format": "prettier --list-different \"**/*.js\"",
"format:fix": "prettier --write \"**/*.{js,json}\"",
"lint": "eslint",
"test": "yarn jest --coverage",
"prepare": "husky"
},
"jestSonar": {
"sonar56x": true,
"reportPath": "reports/coverage",
"reportFile": "sonar-report.xml",
"indent": 4
},
"prettier": {
"printWidth": 100,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "none"
},
"engines": {
"node": ">=20"
},
"peerDependencies": {
"eslint": ">=7"
},
"volta": {
"node": "20.18.0",
"yarn": "1.22.22"
}
],
"homepage": "https://github.com/salesforce/eslint-plugin-lwc-graph-analyzer",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/salesforce/eslint-plugin-lwc-graph-analyzer.git"
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"directories": {
"lib": "lib",
"rules": "lib/rules",
"test": "test"
},
"files": [
"lib/**/*",
"!**/test/**"
],
"devDependencies": {
"@eslint/js": "^9.30.1",
"@typescript-eslint/parser": "^8.35.1",
"chai": "^4.5.0",
"eslint": "^9.28.0",
"eslint-plugin-eslint-plugin": "^6.5.0",
"eslint-plugin-n": "^17.20.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-chain": "^1.1.6",
"jest-extended": "^4.0.2",
"jest-junit": "^16.0.0",
"jest-sonar-reporter": "^2.0.0",
"prettier": "^3.6.2",
"typescript": "^5.8.3",
"typescript-eslint": "^8.35.1"
},
"dependencies": {
"@babel/core": "^7.28.0",
"@babel/eslint-parser": "^7.28.0",
"@komaci/static-analyzer": "^252.1.0",
"@lwc/errors": "~3.5.0",
"@lwc/metadata": "3.5.0-0",
"@lwc/sfdc-compiler-utils": "3.5.0-0",
"@lwc/template-compiler": "~3.5.0",
"@types/eslint": "^9.6.1"
},
"scripts": {
"format": "prettier --list-different \"**/*.js\"",
"format:fix": "prettier --write \"**/*.{js,json}\"",
"lint": "eslint",
"test": "yarn jest --coverage",
"prepare": "husky"
},
"jestSonar": {
"sonar56x": true,
"reportPath": "reports/coverage",
"reportFile": "sonar-report.xml",
"indent": 4
},
"prettier": {
"printWidth": 100,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "none"
},
"engines": {
"node": ">=20"
},
"peerDependencies": {
"eslint": ">=7"
},
"volta": {
"node": "20.18.0",
"yarn": "1.22.22"
}
}
13 changes: 7 additions & 6 deletions test/lib/rules/artifacts-combined-files/fileUpload/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class FileUpload extends LightningElement {

/* eslint-disable */
get fileName() {
// This getter voilates the rule no-getter-contains-more-than-return-statement since it is referenced in the template html
const file = this.files && this.files[0];
if (file) {
return file.name;
Expand All @@ -35,17 +36,16 @@ export default class FileUpload extends LightningElement {
}
/* eslint-enable */

/* eslint-disable @salesforce/lwc-graph-analyzer/no-getter-contains-more-than-return-statement */
// No longer voilating the rule no-getter-contains-more-than-return-statement
get fileName1() {
const file = this.files && this.files[0];
if (file) {
return file.name;
}
return undefined;
}
/* eslint-enable @salesforce/lwc-graph-analyzer/no-getter-contains-more-than-return-statement */

// eslint-disable-next-line
// No longer voilating the rule no-getter-contains-more-than-return-statement
get fileName2() {
const file = this.files && this.files[0];
if (file) {
Expand All @@ -54,7 +54,7 @@ export default class FileUpload extends LightningElement {
return undefined;
}

// eslint-disable-next-line @salesforce/lwc-graph-analyzer/no-getter-contains-more-than-return-statement
// No longer voilating the rule no-getter-contains-more-than-return-statement
get fileName3() {
const file = this.files && this.files[0];
if (file) {
Expand All @@ -64,7 +64,8 @@ export default class FileUpload extends LightningElement {
}

// prettier-ignore
get fileName4() { // eslint-disable-line
// No longer voilating the rule no-getter-contains-more-than-return-statement
get fileName4() {
const file = this.files && this.files[0];
if (file) {
return file.name;
Expand All @@ -73,7 +74,7 @@ export default class FileUpload extends LightningElement {
}

// prettier-ignore
get fileName5() { // eslint-disable-line @salesforce/lwc-graph-analyzer/no-getter-contains-more-than-return-statement
get fileName5() {
const file = this.files && this.files[0];
if (file) {
return file.name;
Expand Down
9 changes: 7 additions & 2 deletions test/lib/rules/artifacts-combined-files/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ function lintBundle(rulePath, target) {
const srcCode = readFileSync(testPath).toString();

const linter = new Linter();
return linter.verify(srcCode, config, { filename: testPath, filterCodeBlock });
return linter.verify(srcCode, config, {
filename: testPath,
filterCodeBlock,
reportUnusedDisableDirectives: false
});
}

/**
Expand All @@ -76,7 +80,8 @@ function lintProgrammaticBundle(rulePath, target) {
const linter = new Linter();
return linter.verify(srcCode, config, {
filename: testPath,
filterCodeBlock
filterCodeBlock,
reportUnusedDisableDirectives: false
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ruleTester.run(
testFunction(val){
return val;
}

@wire(findContacts, { searchKey: '$searchKey' })
contacts;
}`,
filename: 'lwc-code.js',
errors: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ ruleTester.run(
}

@wire(getRecord, { recordId: '$config' })
record(value) {
console.log(value);
}
record1;

@wire(getRecord, { recordId: '$myObjLiteral.prop2' })
record2;
Expand Down
Loading