@open-xchange/linter-presets 0.0.3 → 0.0.4
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
CHANGED
|
@@ -19,3 +19,7 @@
|
|
|
19
19
|
- changed: [ESLint] environment `env.plugin` renamed to `env.eslint`
|
|
20
20
|
- fixed: [StyleLint] support for LESS files
|
|
21
21
|
- chore: update dependencies
|
|
22
|
+
|
|
23
|
+
## [0.0.4] - 2024-07-10
|
|
24
|
+
|
|
25
|
+
- fixed: [ESLint] file exists detection in rule `env-project/no-invalid-modules`
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
|
|
22
22
|
import { createRequire } from "node:module";
|
|
23
23
|
import { posix, dirname, extname } from "node:path";
|
|
24
|
-
import { existsSync } from "node:fs";
|
|
25
24
|
|
|
26
25
|
import { packageUpSync } from "package-up";
|
|
27
26
|
|
|
28
|
-
import { Schema, makeArray, toPosixPath, matchModuleName, getModuleName } from "../shared/rule-utils.js";
|
|
27
|
+
import { Schema, makeArray, toPosixPath, isFile, matchModuleName, getModuleName } from "../shared/rule-utils.js";
|
|
29
28
|
|
|
30
29
|
// constants ==================================================================
|
|
31
30
|
|
|
@@ -106,10 +105,10 @@ export default {
|
|
|
106
105
|
|
|
107
106
|
// returns an existing alias key used by the passed module name
|
|
108
107
|
const resolveAlias = moduleName => {
|
|
109
|
-
const [key, rest] = moduleName.split("/"
|
|
110
|
-
const aliasPath = (key && rest) ? aliasMap.get(key) : undefined;
|
|
108
|
+
const [key, ...rest] = moduleName.split("/");
|
|
109
|
+
const aliasPath = (key && rest[0]) ? aliasMap.get(key) : undefined;
|
|
111
110
|
const aliasKey = aliasPath ? key : "";
|
|
112
|
-
const modulePath = aliasPath ? posix.join(aliasPath, rest) : moduleName;
|
|
111
|
+
const modulePath = aliasPath ? posix.join(aliasPath, ...rest) : moduleName;
|
|
113
112
|
return { aliasKey, modulePath };
|
|
114
113
|
};
|
|
115
114
|
|
|
@@ -117,9 +116,9 @@ export default {
|
|
|
117
116
|
const fileExists = resolvedName => {
|
|
118
117
|
// check modules with explicit extension
|
|
119
118
|
const resolvedPath = posix.join(rootDir, resolvedName);
|
|
120
|
-
if (extname(resolvedName)) { return
|
|
119
|
+
if (extname(resolvedName)) { return isFile(resolvedPath); }
|
|
121
120
|
// search for a file with a known extension
|
|
122
|
-
return FILE_EXTENSIONS.some(ext =>
|
|
121
|
+
return FILE_EXTENSIONS.some(ext => isFile(resolvedPath + "." + ext));
|
|
123
122
|
};
|
|
124
123
|
|
|
125
124
|
// returns whether the passed module name is an installed NPM package
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { posix, sep } from "node:path";
|
|
23
|
+
import { lstatSync } from "node:fs";
|
|
23
24
|
|
|
24
25
|
import pm from "picomatch";
|
|
25
26
|
|
|
@@ -101,6 +102,24 @@ export function toPosixPath(path) {
|
|
|
101
102
|
return path.replaceAll(sep, posix.sep);
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Returns whether the passed path refers to an existing file.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} path
|
|
109
|
+
* The path to be checked.
|
|
110
|
+
*
|
|
111
|
+
* @returns {boolean}
|
|
112
|
+
* Whether the passed path refers to an existing file (returns `false` for
|
|
113
|
+
* existing directories).
|
|
114
|
+
*/
|
|
115
|
+
export function isFile(path) {
|
|
116
|
+
try {
|
|
117
|
+
return lstatSync(path).isFile();
|
|
118
|
+
} catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
104
123
|
/**
|
|
105
124
|
* Returns whether a module name matches the specified glob patterns.
|
|
106
125
|
*
|
package/package.json
CHANGED