Skip to content

Commit

Permalink
Merge pull request #1004 from codacy/fix-codacyrc
Browse files Browse the repository at this point in the history
fix: Read `/.codacyrc` file correctly
  • Loading branch information
lolgab authored Mar 27, 2024
2 parents bbe705e + 0e757c2 commit 378fb07
Showing 2 changed files with 1 addition and 34 deletions.
9 changes: 1 addition & 8 deletions src/configCreator.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
import { ESLint } from "eslint"

import { defaultOptions } from "./eslintDefaultOptions"
import { debug } from "./logging"
import { readCodacyrcFile } from "./fileUtils"

export async function createEslintConfig(
srcDirPath: string
): Promise<[ESLint.Options, string[]]> {
debug("config: creating")

const defaultFilesToAnalyze = [
srcDirPath + "/**"
]
const options = generateEslintOptions(srcDirPath)

const codacyrc = await readCodacyrcFile(srcDirPath + "/.codacyrc")
const codacyrc = await readCodacyrcFile("/.codacyrc")
const files = codacyrc?.files?.length > 0 ? codacyrc.files : defaultFilesToAnalyze

debug("config: finished")
return [options, files]
}

function generateEslintOptions(
srcDirPath: string
): ESLint.Options {
debug("options: creating")

const options = defaultOptions

options.cwd = srcDirPath
options.errorOnUnmatchedPattern = false
options.resolvePluginsRelativeTo = "."
options.useEslintrc = false

debug("options: finished")
return options
}
26 changes: 0 additions & 26 deletions src/logging.ts

This file was deleted.

0 comments on commit 378fb07

Please sign in to comment.