Skip to content

Commit eef8e9e

Browse files
added eslint
1 parent 1bad5cf commit eef8e9e

File tree

7,120 files changed

+964666
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,120 files changed

+964666
-1
lines changed

.github/.DS_Store

6 KB
Binary file not shown.

assertive-detekt-config.yaml

+785
Large diffs are not rendered by default.

detekt-config.yaml

+785
Large diffs are not rendered by default.

detekt.js

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
const { access, constants, readFile, writeFile } = require("node:fs/promises")
2+
const { join } = require("node:path")
3+
4+
async function findConfigFile(repoPath, configFiles) {
5+
for (const configFile of configFiles) {
6+
const configFilePath = join(repoPath, configFile)
7+
if (await fileExists(configFilePath)) {
8+
return true
9+
}
10+
}
11+
return false
12+
}
13+
14+
async function writeDetektConfig( repoPath) {
15+
const configFiles = [
16+
"detekt.yml",
17+
"detekt.yaml",
18+
"detekt-config.yml",
19+
"detekt-config.yaml",
20+
"default-detekt-config.yml",
21+
"default-detekt-config.yaml",
22+
]
23+
24+
const configFileExists = await findConfigFile(repoPath, configFiles)
25+
console.log("Config file exists: ", configFileExists)
26+
if (configFileExists) {
27+
return
28+
}
29+
30+
const isAssertive = "assertive"
31+
32+
// Paths to the config files in the current repository
33+
const assertiveConfigPath = join(process.cwd(), "assertive-detekt-config.yaml")
34+
const nonAssertiveConfigPath = join(process.cwd(), "non-assertive-detekt-config.yaml")
35+
console.log({
36+
assertiveConfigPath,
37+
nonAssertiveConfigPath,
38+
39+
})
40+
41+
// Determine the source config file based on the isAssertive condition
42+
const sourceConfigPath = isAssertive ? assertiveConfigPath : nonAssertiveConfigPath
43+
console.log("Source config path: ", sourceConfigPath)
44+
45+
try {
46+
// Read the content of the chosen YAML config file
47+
const configContent = await readFile(sourceConfigPath, "utf8")
48+
console.log("Config content: ", configContent,typeof configContent)
49+
50+
// Path to the target config file in the cloned repository
51+
const targetConfigPath = join(process.cwd(), "detekt-config.yaml")
52+
console.log("Target config path: ", targetConfigPath)
53+
54+
// Write the content to the target config file
55+
await writeFile(targetConfigPath, configContent, { mode: 0o644 })
56+
57+
console.log(`Detekt config file written to ${targetConfigPath} based on isAssertive = ${isAssertive}`)
58+
} catch (error) {
59+
console.error(`Failed to write Detekt config file: ${error}`)
60+
}
61+
}
62+
63+
async function fileExists(file) {
64+
try {
65+
await access(file, constants.F_OK)
66+
return true
67+
} catch {
68+
return false
69+
}
70+
}
71+
72+
// Example usage
73+
async function exampleUsage() {
74+
const repoPath = '/path/to/cloned/repo' // Update this to the actual path of the cloned repo
75+
76+
77+
await writeDetektConfig(repoPath)
78+
}
79+
80+
exampleUsage().catch(console.error)

eslint.config.mjs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
5+
import { fixupConfigRules } from "@eslint/compat";
6+
7+
8+
export default [
9+
{
10+
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
11+
languageOptions: {
12+
parserOptions: {
13+
ecmaFeatures: { jsx: true },
14+
},
15+
globals: globals.browser,
16+
},
17+
rules: {
18+
...pluginJs.configs.recommended.rules,
19+
...tseslint.configs.recommended.rules,
20+
...fixupConfigRules(pluginReactConfig).rules,
21+
},
22+
},
23+
];

node_modules/.bin/acorn

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/eslint

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/js-yaml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/loose-envify

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/node-which

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/resolve

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/semver

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/tsc

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/tsserver

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)