Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX (ESLint): @W-12608309@: Fixed import for relocated ESLint configs. #988

Merged
merged 1 commit into from
Feb 27, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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