Skip to content

Commit

Permalink
Merge pull request #988 from forcedotcom/d/W-12608309
Browse files Browse the repository at this point in the history
FIX (ESLint): @W-12608309@: Fixed import for relocated ESLint configs.
  • Loading branch information
jfeingold35 committed Feb 27, 2023
2 parents 86f5ba9 + 495c595 commit 00c150a
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 339 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@babel/core": "^7.11.0",
"@babel/eslint-parser": "^7",
"@eslint/js": "^8.35.0",
"@lwc/eslint-plugin-lwc": "^1.1.2",
"@oclif/command": "^1",
"@oclif/config": "^1",
Expand All @@ -19,7 +20,7 @@
"@typescript-eslint/parser": "^5.14.0",
"cross-spawn": "^7.0.3",
"csv-stringify": "^6.0.5",
"eslint": "^8.10.0",
"eslint": "^8.35.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
"find-java-home": "1.2.2",
Expand Down Expand Up @@ -75,7 +76,7 @@
"@types/uuid": "^8.3.4",
"chai": "^4",
"cross-env": "^7.0.3",
"eslint": "^8.10.0",
"eslint": "^8.35.0",
"mocha": "^9",
"mocha-junit-reporter": "^2.0.0",
"nyc": "^15.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/eslint/JavascriptEslintStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {ENGINE, LANGUAGE, HARDCODED_RULES} from '../../Constants';
import {ESRule, ESRuleConfigValue, ESRuleConfig, RuleViolation} from '../../types';
import { Logger } from '@salesforce/core';
import {EslintStrategyHelper, ProcessRuleViolationType, RuleDefaultStatus} from './EslintCommons';
import path = require('path');
import {ESLint} from 'eslint';
import {configs} from '@eslint/js';

const ES_CONFIG: ESLint.Options = {
"baseConfig": {},
Expand Down Expand Up @@ -41,8 +41,8 @@ export class JavascriptEslintStrategy implements EslintStrategy {
this.logger = await Logger.child(this.getEngine().valueOf());
// When we're building our catalog, we'll want to get any bonus configuration straight from the horse's mouth.
// This lets us do that.
const pathToRecommendedConfig = require.resolve('eslint').replace(path.join('lib', 'api.js'), path.join('conf', 'eslint-recommended.js'));
this.recommendedConfig = (await import(pathToRecommendedConfig)) as ESRuleConfig;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
this.recommendedConfig = configs.recommended as ESRuleConfig;
this.initialized = true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/eslint/TypescriptEslintStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {deepCopy} from '../util/Utils';
import { rules } from '@typescript-eslint/eslint-plugin';
import {EslintStrategyHelper, ProcessRuleViolationType, RuleDefaultStatus} from './EslintCommons';
import {ESLint} from 'eslint';
import {configs} from '@eslint/js';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/sfdx-scanner', 'TypescriptEslintStrategy');
Expand Down Expand Up @@ -61,9 +62,8 @@ export class TypescriptEslintStrategy implements EslintStrategy {
this.logger = await Logger.child(this.getEngine().valueOf());
this.fileHandler = new FileHandler();
this.outputProcessor = await OutputProcessor.create({});
const pathToBaseConfig = require.resolve('eslint')
.replace(path.join('lib', 'api.js'), path.join('conf', 'eslint-recommended.js'));
this.baseEslintConfig = (await import(pathToBaseConfig)) as ESRuleConfig;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
this.baseEslintConfig = configs.recommended as ESRuleConfig;

const pathToExtendedBaseConfig = require.resolve('@typescript-eslint/eslint-plugin')
.replace('index.js', path.join('configs', 'eslint-recommended.js'));
Expand Down
2 changes: 1 addition & 1 deletion test/code-fixtures/projects/js/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"root": true
"root": true,
"extends": ["eslint:recommended"],
"parserOptions": {
"sourceType": "module",
Expand Down

0 comments on commit 00c150a

Please sign in to comment.