Skip to content

Commit 0350ed0

Browse files
authored
Merge pull request #79 from atom-community/type-module
2 parents 9f43efc + 8e5ab6e commit 0350ed0

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/index.cts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ import { csonConfig } from "./cson.cjs"
66
import { yamlConfig } from "./yaml.cjs"
77
import { htmlConfig } from "./html.cjs"
88
import { pluginImportSettings } from "./plugin-import-rules.cjs"
9-
import semverLt from "semver/functions/lt"
9+
import semverMajor from "semver/functions/major"
1010
import { getEslintVersion } from "./eslint-version.cjs"
1111

12-
const overrides = [tsConfig, jsonConfig, yamlConfig, htmlConfig]
13-
14-
// add coffee if installed
15-
try {
16-
// check if the eslint version is >= 8
17-
if (semverLt(getEslintVersion(), "8.0.0")) {
18-
// if so try adding the coffee plugin
19-
const found = require.resolve("eslint-plugin-coffee")
20-
if (found) {
21-
overrides.push(coffeeConfig, csonConfig)
12+
function maybeAddCoffeeScript() {
13+
try {
14+
const eslintVersion = semverMajor(getEslintVersion())
15+
// check if the eslint version is < 8
16+
// and if coffee installed
17+
if (eslintVersion < 8 && require.resolve("eslint-plugin-coffee")) {
18+
// if so try adding the coffee plugin
19+
return [coffeeConfig, csonConfig]
2220
}
21+
} catch (_err) {
22+
// optional plugin
2323
}
24-
} catch (_err) {
25-
// optional plugin
24+
return []
2625
}
2726

2827
const config = {
@@ -39,7 +38,7 @@ const config = {
3938
measure: "readonly",
4039
},
4140
...jsConfig,
42-
overrides,
41+
overrides: [tsConfig, jsonConfig, yamlConfig, htmlConfig, ...maybeAddCoffeeScript()],
4342
settings: {
4443
...pluginImportSettings,
4544
},

0 commit comments

Comments
 (0)