@open-xchange/linter-presets 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/eslint/shared/rule-utils.js +14 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ import { findUpSync } from "find-up";
|
|
|
6
6
|
import { AST_NODE_TYPES as NodeType } from "@typescript-eslint/utils";
|
|
7
7
|
// constants ==================================================================
|
|
8
8
|
const FILE_EXTENSIONS = ["js", "ts", "d.ts"];
|
|
9
|
+
const CONFIG_FILES = [
|
|
10
|
+
"eslint.config.js",
|
|
11
|
+
"eslint.config.mjs",
|
|
12
|
+
"eslint.config.cjs",
|
|
13
|
+
"eslint.config.ts",
|
|
14
|
+
"eslint.config.mts",
|
|
15
|
+
"eslint.config.cts",
|
|
16
|
+
];
|
|
9
17
|
// Schema =====================================================================
|
|
10
18
|
/**
|
|
11
19
|
* Helper functions to build a JSON schema for custom ESLint rules.
|
|
@@ -133,10 +141,13 @@ export class ProjectContext {
|
|
|
133
141
|
const sharedSettings = context.settings["env-project"];
|
|
134
142
|
this.#aliasMap = new Map(Object.entries(sharedSettings?.alias ?? {}));
|
|
135
143
|
// resolve root directory
|
|
136
|
-
const configPath = findUpSync(
|
|
137
|
-
|
|
144
|
+
const configPath = findUpSync(CONFIG_FILES);
|
|
145
|
+
if (!configPath) {
|
|
146
|
+
throw new Error("cannot find configuration file");
|
|
147
|
+
}
|
|
148
|
+
const rootDir = toPosixPath(dirname(configPath));
|
|
138
149
|
const fileName = toPosixPath(context.filename);
|
|
139
|
-
if (!
|
|
150
|
+
if (!fileName.startsWith(rootDir + "/")) {
|
|
140
151
|
throw new Error("invalid root directory");
|
|
141
152
|
}
|
|
142
153
|
this.#rootDir = rootDir;
|