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
42 changes: 42 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,48 @@
"NODE_OPTIONS": "--experimental-vm-modules"
},
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug engine.test.ts (single test)",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"packages/code-analyzer-eslint-engine/test/engine.test.ts",
"-t",
"When file_extensions is only .tsx, then only react rules are returned",
"--runInBand",
"--coverage=false"
],
"env": {
"NODE_OPTIONS": "--experimental-vm-modules"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
"name": "Debug Jest (watch all)",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--runInBand",
"--coverage=false",
"--watch"
],
"env": {
"NODE_OPTIONS": "--experimental-vm-modules"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**"
]
}
]
}
14 changes: 9 additions & 5 deletions packages/code-analyzer-eslint-engine/src/base-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,13 @@ export class BaseConfigFactory {
* Note: TypeScript React support (.tsx) is planned for the next iteration.
*/
private createReactConfigArray(): Linter.Config[] {
// Apply React rules to all JavaScript files
// Apply React rules to all JavaScript and TypeScript files

const jsExtensions = this.engineConfig.file_extensions.javascript;
const tsExtensions = this.engineConfig.file_extensions.typescript;
const reactExtensions = [...new Set([...jsExtensions, ...tsExtensions])];

if (jsExtensions.length === 0) {
if (reactExtensions.length === 0) {
return [];
}

Expand All @@ -211,7 +214,7 @@ export class BaseConfigFactory {

return [{
...reactAllConfig,
files: jsExtensions.map(ext => `**/*${ext}`),
files: reactExtensions.map(ext => `**/*${ext}`),
settings: {
...reactAllConfig.settings,
react: {
Expand Down Expand Up @@ -246,9 +249,10 @@ export class BaseConfigFactory {

private useReactBaseConfig(): boolean {
// React config is independently controlled by disable_react_base_config
// React rules apply to all JS files - no harm if file has no React code
// React rules apply to all JS and TS files - no harm if file has no React code
return !this.engineConfig.disable_react_base_config &&
this.engineConfig.file_extensions.javascript.length > 0;
(this.engineConfig.file_extensions.javascript.length > 0 ||
this.engineConfig.file_extensions.typescript.length > 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/code-analyzer-eslint-engine/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const DEFAULT_CONFIG: ESLintEngineConfig = {
disable_react_base_config: true, // Gated for now - will change to false when released
file_extensions: {
javascript: ['.js', '.cjs', '.mjs', '.jsx'],
typescript: ['.ts'], // Note: .tsx support planned for next iteration
typescript: ['.ts', '.tsx'],
html: ['.html', '.htm', '.cmp'],
css: ['.css', '.scss'],
other: []
Expand Down
2,118 changes: 14 additions & 2,104 deletions packages/code-analyzer-eslint-engine/src/rule-mappings.ts

Large diffs are not rendered by default.

2,106 changes: 2,106 additions & 0 deletions packages/code-analyzer-eslint-engine/src/rule-mappings.ts.bak

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Convenience tag to apply to framework specific rules
export const LWC = "LWC";
export const SLDS = "SLDS";
export const REACT = "React";
805 changes: 805 additions & 0 deletions packages/code-analyzer-eslint-engine/src/rule-mappings/eslint-base.ts

Large diffs are not rendered by default.

Loading