Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1,638 changes: 1,048 additions & 590 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions packages/ENGINE-TEMPLATE/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"types": "dist/index.d.ts",
"dependencies": {
"@types/node": "^20.0.0",
"@salesforce/code-analyzer-engine-api": "0.30.0"
"@salesforce/code-analyzer-engine-api": "0.31.0-SNAPSHOT"
},
"devDependencies": {
"@eslint/js": "^9.35.0",
"@eslint/js": "^9.38.0",
"@types/jest": "^30.0.0",
"eslint": "^9.35.0",
"jest": "^30.1.3",
"eslint": "^9.38.0",
"jest": "^30.2.0",
"rimraf": "^6.0.1",
"ts-jest": "^29.4.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.44.0"
"ts-jest": "^29.4.5",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.2"
},
"engines": {
"node": ">=20.0.0"
Expand Down Expand Up @@ -60,4 +60,4 @@
"!src/index.ts"
]
}
}
}
18 changes: 9 additions & 9 deletions packages/code-analyzer-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
},
"types": "dist/index.d.ts",
"dependencies": {
"@salesforce/code-analyzer-engine-api": "0.30.0",
"@salesforce/code-analyzer-engine-api": "0.31.0-SNAPSHOT",
"@types/node": "^20.0.0",
"csv-stringify": "^6.6.0",
"js-yaml": "^4.1.0",
"semver": "^7.7.2",
"semver": "^7.7.3",
"xmlbuilder": "^15.1.1"
},
"devDependencies": {
"@eslint/js": "^9.35.0",
"@eslint/js": "^9.38.0",
"@types/js-yaml": "^4.0.9",
"@types/jest": "^30.0.0",
"@types/sarif": "^2.1.7",
"@types/semver": "^7.7.1",
"cross-env": "^10.0.0",
"eslint": "^9.35.0",
"jest": "^30.1.3",
"cross-env": "^10.1.0",
"eslint": "^9.38.0",
"jest": "^30.2.0",
"rimraf": "^6.0.1",
"ts-jest": "^29.4.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.44.0"
"ts-jest": "^29.4.5",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.2"
},
"engines": {
"node": ">=20.0.0"
Expand Down
16 changes: 8 additions & 8 deletions packages/code-analyzer-engine-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/code-analyzer-engine-api",
"description": "Engine API Package for the Salesforce Code Analyzer",
"version": "0.30.0",
"version": "0.31.0-SNAPSHOT",
"author": "The Salesforce Code Analyzer Team",
"license": "BSD-3-Clause",
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
Expand All @@ -19,14 +19,14 @@
"@types/node": "^20.0.0"
},
"devDependencies": {
"@eslint/js": "^9.35.0",
"@eslint/js": "^9.38.0",
"@types/jest": "^30.0.0",
"eslint": "^9.35.0",
"jest": "^30.1.3",
"eslint": "^9.38.0",
"jest": "^30.2.0",
"rimraf": "^6.0.1",
"ts-jest": "^29.4.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.44.0"
"ts-jest": "^29.4.5",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.2"
},
"engines": {
"node": ">=20.0.0"
Expand Down Expand Up @@ -63,4 +63,4 @@
"!src/utils/index.ts"
]
}
}
}
26 changes: 13 additions & 13 deletions packages/code-analyzer-eslint-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/code-analyzer-eslint-engine",
"description": "Plugin package that adds 'eslint' as an engine into Salesforce Code Analyzer",
"version": "0.35.0",
"version": "0.36.0-SNAPSHOT",
"author": "The Salesforce Code Analyzer Team",
"license": "BSD-3-Clause",
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
Expand All @@ -13,33 +13,33 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"@eslint/js": "^9.35.0",
"@eslint/js": "^9.38.0",
"@lwc/eslint-plugin-lwc": "^3.2.0",
"@lwc/eslint-plugin-lwc-platform": "^6.1.0",
"@lwc/eslint-plugin-lwc-platform": "^6.3.0",
"@salesforce-ux/eslint-plugin-slds": "^1.0.2",
"@salesforce/code-analyzer-engine-api": "0.30.0",
"@salesforce/code-analyzer-eslint8-engine": "0.7.0",
"@salesforce/code-analyzer-engine-api": "0.31.0-SNAPSHOT",
"@salesforce/code-analyzer-eslint8-engine": "0.8.0-SNAPSHOT",
"@salesforce/eslint-config-lwc": "^4.0.0",
"@salesforce/eslint-plugin-lightning": "^2.0.0",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^8.44.0",
"@typescript-eslint/parser": "^8.44.0",
"eslint": "^9.35.0",
"eslint": "^9.38.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.0.1",
"globals": "^16.4.0",
"semver": "^7.7.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.44.0"
"semver": "^7.7.3",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.2"
},
"devDependencies": {
"@types/jest": "^30.0.0",
"@types/semver": "^7.7.1",
"@types/unzipper": "^0.10.11",
"cross-env": "^10.0.0",
"jest": "^30.1.3",
"cross-env": "^10.1.0",
"jest": "^30.2.0",
"rimraf": "^6.0.1",
"ts-jest": "^29.4.2",
"ts-jest": "^29.4.5",
"unzipper": "^0.12.3"
},
"engines": {
Expand Down Expand Up @@ -76,4 +76,4 @@
"!src/index.ts"
]
}
}
}
60 changes: 30 additions & 30 deletions packages/code-analyzer-eslint-engine/src/base-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import globals from "globals";

export class BaseConfigFactory {
private readonly engineConfig: ESLintEngineConfig;

constructor(engineConfig: ESLintEngineConfig) {
this.engineConfig = engineConfig;
}

createBaseConfigArray(): Linter.Config[] {
const configArray: Linter.Config[] = [{
linterOptions: {
Expand All @@ -28,7 +28,7 @@ export class BaseConfigFactory {
"$Label": "readonly", // ^
"$Locale": "readonly", // ^
"$Resource": "readonly", // ^

// ESLint doesn't natively know about various browser and node globals. So we add them here to
// remove false positives for our users.
... globals.node,
Expand All @@ -37,7 +37,7 @@ export class BaseConfigFactory {
}
}
}];

if (this.useJsBaseConfig() && this.useLwcBaseConfig()) {
configArray.push(...this.createJavascriptPlusLwcConfigArray());
} else if (this.useJsBaseConfig()) {
Expand All @@ -56,22 +56,22 @@ export class BaseConfigFactory {
}
return configArray;
}

private createJavascriptPlusLwcConfigArray(): Linter.Config[] {
let configs: Linter.Config[] = validateAndGetRawLwcConfigArray();

// TODO: Remove the For the following 2 updates when https://github.com/salesforce/eslint-config-lwc/issues/158 is fixed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfeingold35 is turning this off still necessary? It looks like the original bug was turned off (not sure if this eslint plugin still needs to update or if that og bug being fixed is sufficient)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Issue is still open, so I think it might still be necessary.

// 1) Turn off the babel parser's configFile option from the lwc base plugin
configs[0].languageOptions!.parserOptions!.babelOptions.configFile = false;
(configs[0].languageOptions!.parserOptions as Linter.ParserOptions).babelOptions.configFile = false;
// 2) For some reason babel doesn't like .cjs files unless we explicitly set this to undefined because I think
// ESLint 9 is setting it to "commonjs" automatically when the field doesn't exist in the parserOptions (and for
// babel "commonjs" isn't a valid option)
configs[0].languageOptions!.parserOptions!.sourceType = undefined;
(configs[0].languageOptions!.parserOptions as Linter.ParserOptions).sourceType = undefined;

// Swap out eslintJs.configs.recommended with eslintJs.configs.all
configs[1] = eslintJs.configs.all;
// This one rule makes eslint throw an exception if the user doesn't have jest installed (which should be

// This one rule makes eslint throw an exception if the user doesn't have jest installed (which should be
// optional), so we turn it off for now. See https://github.com/salesforce/eslint-config-lwc/issues/161
configs[3].rules = {
...configs[3].rules,
Expand All @@ -84,41 +84,41 @@ export class BaseConfigFactory {
...configs[5].rules,
'@lwc/lwc-platform/valid-offline-wire': 'off'
}

// Restrict these configs to just javascript files
configs = configs.map(config => {
return {
...config,
files: this.engineConfig.file_extensions.javascript.map(ext => `**/*${ext}`)
}
});

return configs;
}

private createLwcConfigArray(): Linter.Config[] {
const configs: Linter.Config[] = this.createJavascriptPlusLwcConfigArray();

// Remove any explicitly listed rule that is a base javascript rule from the recommended LWC/Lightning rules.
// Note the modified base rules don't have namespace like jest/*, @lwc/*, etc (and thus has no '/').
configs[4].rules = Object.fromEntries(
Object.entries(configs[4].rules as Linter.RulesRecord).filter(([key]) => key.includes('/'))
);

// Remove the eslintJs.configs.all (at element 1). Note that this delete is after the configs[4] update above so
// we can work with the original index [4] instead of [3] to avoid confusion.
configs.splice(1, 1);

return configs;
}

private createJavascriptConfigArray(): Linter.Config[] {
return [{
... eslintJs.configs.all,
files: this.engineConfig.file_extensions.javascript.map(ext => `**/*${ext}`)
}];
}

private createSldsHTMLConfigArray(): Linter.Config[] {
return sldsEslintPlugin.configs['flat/recommended-html'].map((htmlConfig: Linter.Config) => {
return {
Expand All @@ -127,16 +127,16 @@ export class BaseConfigFactory {
};
});
}
private createSldsCSSConfigArray(): Linter.Config[] {

private createSldsCSSConfigArray(): Linter.Config[] {
return sldsEslintPlugin.configs['flat/recommended-css'].map((cssConfig: Linter.Config) => {
return {
...cssConfig,
files: this.engineConfig.file_extensions.css.map(ext => `**/*${ext}`)
};
});
}

private createTypescriptConfigArray(): Linter.Config[] {
const configs: Linter.Config[] = [];
for (const conf of ([eslintJs.configs.all, ...eslintTs.configs.all] as Linter.Config[])) {
Expand All @@ -147,7 +147,7 @@ export class BaseConfigFactory {
... (conf.languageOptions ?? {}),
parserOptions: {
... (conf.languageOptions?.parserOptions ?? {}),

// Finds the tsconfig.json file nearest to each source file. This should work for most users.
// If not, then we may consider letting user specify this via config or alternatively users can
// just set disable_typescript_base_config=true and configure typescript in their own eslint
Expand All @@ -159,23 +159,23 @@ export class BaseConfigFactory {
}
return configs;
}

private useJsBaseConfig(): boolean {
return !this.engineConfig.disable_javascript_base_config && this.engineConfig.file_extensions.javascript.length > 0;
}

private useLwcBaseConfig(): boolean {
return !this.engineConfig.disable_lwc_base_config && this.engineConfig.file_extensions.javascript.length > 0;
}

private useSldsCSSBaseConfig(): boolean {
return !this.engineConfig.disable_slds_base_config && this.engineConfig.file_extensions.css.length > 0;
}

private useSldsHTMLBaseConfig(): boolean {
return !this.engineConfig.disable_slds_base_config && this.engineConfig.file_extensions.html.length > 0;
}

private useTsBaseConfig(): boolean {
return !this.engineConfig.disable_typescript_base_config && this.engineConfig.file_extensions.typescript.length > 0;
}
Expand Down Expand Up @@ -206,13 +206,13 @@ function validateAndGetRawLwcConfigArray(): Linter.Config[] {
// - and lib/configs/recommended.js of https://www.npmjs.com/package/@lwc/eslint-plugin-lwc-platform?activeTab=code
throw new Error("INTERNAL ERROR: The recommended config for @salesforce/eslint-config-lwc or @lwc/eslint-plugin-lwc-platform must have changed.");
}

// Return a shallow copy since we will be making modifications
return rawLwcConfigs.map(config => { return {... config}});
}

function containsBabelOptions(config: Linter.Config): boolean {
return config.languageOptions?.parserOptions?.babelOptions !== undefined;
return (config.languageOptions?.parserOptions as Linter.ParserOptions)?.babelOptions !== undefined;
}

function hasRule(config: Linter.Config, ruleName: string): boolean {
Expand Down
12 changes: 10 additions & 2 deletions packages/code-analyzer-eslint-engine/src/rule-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,10 @@ export const RULE_MAPPINGS: Record<string, {severity: SeverityLevel, tags: strin
severity: SeverityLevel.Moderate,
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
},
"@lwc/lwc-platform/no-interop-execute-controller-with-client-def": {
severity: SeverityLevel.Moderate,
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
},
"@lwc/lwc-platform/no-interop-execute-with-callback": {
severity: SeverityLevel.Moderate,
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
Expand Down Expand Up @@ -911,6 +915,10 @@ export const RULE_MAPPINGS: Record<string, {severity: SeverityLevel, tags: strin
severity: SeverityLevel.Moderate,
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
},
"@lwc/lwc-platform/no-lds-aura-controller-method": {
severity: SeverityLevel.Moderate,
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
},
"@lwc/lwc-platform/no-process-env": {
severity: SeverityLevel.Moderate,
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
Expand Down Expand Up @@ -1041,7 +1049,7 @@ export const RULE_MAPPINGS: Record<string, {severity: SeverityLevel, tags: strin
tags: [COMMON_TAGS.RECOMMENDED, LWC, COMMON_TAGS.CATEGORIES.ERROR_PRONE, COMMON_TAGS.LANGUAGES.JAVASCRIPT]
},

// This one rule makes eslint throw an exception if the user doesn't have jest installed (which should be
// This one rule makes eslint throw an exception if the user doesn't have jest installed (which should be
// optional), so we turn it off for now. See https://github.com/salesforce/eslint-config-lwc/issues/161
// "jest/no-deprecated-functions": {
// severity: SeverityLevel.Moderate,
Expand Down Expand Up @@ -1604,7 +1612,7 @@ export const RULE_MAPPINGS: Record<string, {severity: SeverityLevel, tags: strin
severity: SeverityLevel.Moderate,
tags: [/* NOT RECOMMENDED */ COMMON_TAGS.CATEGORIES.BEST_PRACTICES, COMMON_TAGS.LANGUAGES.TYPESCRIPT]
},

// =================================================================================================================
// SLDS - HTML BASE RULES - @salesforce-ux/eslint-plugin-slds
// =================================================================================================================
Expand Down
Loading