@plugjs/eslint-plugin 0.2.26 → 0.3.0

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/configs/basic.mjs CHANGED
@@ -1,9 +1,7 @@
1
- import globals from 'globals'
1
+ import stylisticPlugin from '@stylistic/eslint-plugin'
2
+ import importxPlugin from 'eslint-plugin-import-x'
2
3
  import unicornPlugin from 'eslint-plugin-unicorn'
3
-
4
- import importxPlugin from '../bundles/eslint-plugin-import-x.cjs'
5
- import stylisticPlugin from '../bundles/stylistic-eslint-plugin.cjs'
6
- import '../bundles/eslint-import-resolver-typescript.cjs' // preload!
4
+ import globals from 'globals'
7
5
 
8
6
  /* ========================================================================== */
9
7
 
@@ -152,9 +150,8 @@ export const importx = {
152
150
  'espree': [ '.js', '.mjs', '.cjs' ],
153
151
  },
154
152
  'import-x/resolver': {
155
- // point to our bundled-in typescript *and* node resolvers...
156
- '../bundles/eslint-import-resolver-typescript.cjs': true,
157
- '../bundles/eslint-import-resolver-node.cjs': true,
153
+ 'eslint-import-resolver-typescript': true,
154
+ 'eslint-import-resolver-node': true,
158
155
  },
159
156
  },
160
157
 
package/index.mjs CHANGED
@@ -6,6 +6,7 @@ import typescript from './configs/typescript.mjs'
6
6
 
7
7
  export * from './configs/basic.mjs'
8
8
  export * from './configs/javascript.mjs'
9
+ export * from './configs/typescript.mjs'
9
10
 
10
11
  /**
11
12
  * Base `ESLint` configuration for PlugJS.
package/package.json CHANGED
@@ -1,22 +1,33 @@
1
1
  {
2
2
  "name": "@plugjs/eslint-plugin",
3
- "version": "0.2.26",
3
+ "version": "0.3.0",
4
4
  "description": "Shared ESLint configurations and extras",
5
5
  "main": "./index.mjs",
6
6
  "type": "module",
7
7
  "author": "Team Juit <developers@juit.com>",
8
8
  "license": "Apache-2.0",
9
9
  "scripts": {
10
- "build": "eslint"
10
+ "build": "node check.mjs && eslint"
11
+ },
12
+ "dependencies": {
13
+ "@eslint/js": "^9.15.0",
14
+ "@stylistic/eslint-plugin": "^2.11.0",
15
+ "eslint-import-resolver-node": "^0.3.9",
16
+ "eslint-import-resolver-typescript": "^3.6.3",
17
+ "eslint-plugin-import-x": "^4.4.2",
18
+ "eslint-plugin-unicorn": "^56.0.1",
19
+ "globals": "^15.12.0",
20
+ "typescript-eslint": "^8.15.0"
21
+ },
22
+ "devDependencies": {
23
+ "eslint": "^9.15.0"
11
24
  },
12
25
  "peerDependencies": {
13
- "eslint": "^9.14.0"
26
+ "eslint": "^9.15.0"
14
27
  },
15
28
  "files": [
16
29
  "*.md",
17
- "bundles/",
18
30
  "configs/",
19
- "eslint.config.mjs",
20
31
  "index.mjs"
21
32
  ],
22
33
  "repository": {
@@ -33,33 +44,5 @@
33
44
  "bugs": {
34
45
  "url": "https://github.com/plugjs/eslint-plugin/issues"
35
46
  },
36
- "homepage": "https://github.com/plugjs/eslint-plugin#readme",
37
- "dependencies": {
38
- "@eslint/js": "9.14.0",
39
- "@nolyfill/is-core-module": "1.0.39",
40
- "@typescript-eslint/utils": "8.14.0",
41
- "debug": "4.3.7",
42
- "doctrine": "3.0.0",
43
- "enhanced-resolve": "5.17.1",
44
- "eslint": "9.14.0",
45
- "eslint-module-utils": "2.12.0",
46
- "eslint-plugin-unicorn": "56.0.0",
47
- "eslint-visitor-keys": "4.2.0",
48
- "espree": "10.3.0",
49
- "estraverse": "5.3.0",
50
- "fast-glob": "3.3.2",
51
- "get-tsconfig": "4.8.1",
52
- "globals": "15.12.0",
53
- "is-bun-module": "1.2.1",
54
- "is-core-module": "2.15.1",
55
- "is-glob": "4.0.3",
56
- "minimatch": "9.0.5",
57
- "picomatch": "4.0.2",
58
- "resolve": "1.22.8",
59
- "semver": "7.6.3",
60
- "stable-hash": "0.0.4",
61
- "tslib": "2.8.1",
62
- "typescript": "5.6.3",
63
- "typescript-eslint": "8.14.0"
64
- }
65
- }
47
+ "homepage": "https://github.com/plugjs/eslint-plugin#readme"
48
+ }
@@ -1,64 +0,0 @@
1
- "use strict";
2
-
3
- // node_modules/eslint-import-resolver-node/index.js
4
- var resolve = require("resolve/sync");
5
- var isCoreModule = require("is-core-module");
6
- var path = require("path");
7
- var log = require("debug")("eslint-plugin-import:resolver:node");
8
- exports.interfaceVersion = 2;
9
- exports.resolve = function(source, file, config) {
10
- log("Resolving:", source, "from:", file);
11
- let resolvedPath;
12
- if (isCoreModule(source)) {
13
- log("resolved to core");
14
- return { found: true, path: null };
15
- }
16
- try {
17
- const cachedFilter = function(pkg, dir) {
18
- return packageFilter(pkg, dir, config);
19
- };
20
- resolvedPath = resolve(source, opts(file, config, cachedFilter));
21
- log("Resolved to:", resolvedPath);
22
- return { found: true, path: resolvedPath };
23
- } catch (err) {
24
- log("resolve threw error:", err);
25
- return { found: false };
26
- }
27
- };
28
- function opts(file, config, packageFilter2) {
29
- return Object.assign({
30
- // more closely matches Node (#333)
31
- // plus 'mjs' for native modules! (#939)
32
- extensions: [".mjs", ".js", ".json", ".node"]
33
- }, config, {
34
- // path.resolve will handle paths relative to CWD
35
- basedir: path.dirname(path.resolve(file)),
36
- packageFilter: packageFilter2
37
- });
38
- }
39
- function identity(x) {
40
- return x;
41
- }
42
- function packageFilter(pkg, dir, config) {
43
- let found = false;
44
- const file = path.join(dir, "dummy.js");
45
- if (pkg.module) {
46
- try {
47
- resolve(String(pkg.module).replace(/^(?:\.\/)?/, "./"), opts(file, config, identity));
48
- pkg.main = pkg.module;
49
- found = true;
50
- } catch (err) {
51
- log("resolve threw error trying to find pkg.module:", err);
52
- }
53
- }
54
- if (!found && pkg["jsnext:main"]) {
55
- try {
56
- resolve(String(pkg["jsnext:main"]).replace(/^(?:\.\/)?/, "./"), opts(file, config, identity));
57
- pkg.main = pkg["jsnext:main"];
58
- found = true;
59
- } catch (err) {
60
- log("resolve threw error trying to find pkg['jsnext:main']:", err);
61
- }
62
- }
63
- return pkg;
64
- }
@@ -1,278 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // node_modules/eslint-import-resolver-typescript/lib/index.js
30
- var lib_exports = {};
31
- __export(lib_exports, {
32
- defaultConditionNames: () => defaultConditionNames,
33
- defaultExtensionAlias: () => defaultExtensionAlias,
34
- defaultExtensions: () => defaultExtensions,
35
- defaultMainFields: () => defaultMainFields,
36
- interfaceVersion: () => interfaceVersion,
37
- resolve: () => resolve
38
- });
39
- module.exports = __toCommonJS(lib_exports);
40
- var import_node_fs = __toESM(require("node:fs"), 1);
41
- var import_node_path = __toESM(require("node:path"), 1);
42
- var import_is_core_module = __toESM(require("@nolyfill/is-core-module"), 1);
43
- var import_debug = __toESM(require("debug"), 1);
44
- var import_enhanced_resolve = __toESM(require("enhanced-resolve"), 1);
45
- var import_hash = require("eslint-module-utils/hash.js");
46
- var import_fast_glob = __toESM(require("fast-glob"), 1);
47
- var import_get_tsconfig = require("get-tsconfig");
48
- var import_is_bun_module = require("is-bun-module");
49
- var import_is_glob = __toESM(require("is-glob"), 1);
50
- var { globSync } = import_fast_glob.default;
51
- var IMPORTER_NAME = "eslint-import-resolver-typescript";
52
- var log = (0, import_debug.default)(IMPORTER_NAME);
53
- var defaultConditionNames = [
54
- "types",
55
- "import",
56
- "esm2020",
57
- "es2020",
58
- "es2015",
59
- "require",
60
- "node",
61
- "node-addons",
62
- "browser",
63
- "default"
64
- ];
65
- var defaultExtensions = [
66
- ".ts",
67
- ".tsx",
68
- ".d.ts",
69
- ".js",
70
- ".jsx",
71
- ".json",
72
- ".node"
73
- ];
74
- var defaultExtensionAlias = {
75
- ".js": [
76
- ".ts",
77
- ".tsx",
78
- ".d.ts",
79
- ".js"
80
- ],
81
- ".jsx": [".tsx", ".d.ts", ".jsx"],
82
- ".cjs": [".cts", ".d.cts", ".cjs"],
83
- ".mjs": [".mts", ".d.mts", ".mjs"]
84
- };
85
- var defaultMainFields = [
86
- "types",
87
- "typings",
88
- "fesm2020",
89
- "fesm2015",
90
- "esm2020",
91
- "es2020",
92
- "module",
93
- "jsnext:main",
94
- "main"
95
- ];
96
- var interfaceVersion = 2;
97
- var fileSystem = import_node_fs.default;
98
- var JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/;
99
- var RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/;
100
- var previousOptionsHash;
101
- var optionsHash;
102
- var cachedOptions;
103
- var prevCwd;
104
- var mappersCachedOptions;
105
- var mappers;
106
- var resolverCachedOptions;
107
- var resolver;
108
- var digestHashObject = (value) => (0, import_hash.hashObject)(value ?? {}).digest("hex");
109
- function resolve(source, file, options) {
110
- if (!cachedOptions || previousOptionsHash !== (optionsHash = digestHashObject(options))) {
111
- previousOptionsHash = optionsHash;
112
- cachedOptions = {
113
- ...options,
114
- conditionNames: options?.conditionNames ?? defaultConditionNames,
115
- extensions: options?.extensions ?? defaultExtensions,
116
- extensionAlias: options?.extensionAlias ?? defaultExtensionAlias,
117
- mainFields: options?.mainFields ?? defaultMainFields,
118
- fileSystem: new import_enhanced_resolve.default.CachedInputFileSystem(fileSystem, 5 * 1e3),
119
- useSyncFileSystemCalls: true
120
- };
121
- }
122
- if (!resolver || resolverCachedOptions !== cachedOptions) {
123
- resolver = import_enhanced_resolve.default.ResolverFactory.createResolver(cachedOptions);
124
- resolverCachedOptions = cachedOptions;
125
- }
126
- log("looking for:", source);
127
- source = removeQuerystring(source);
128
- if ((0, import_is_core_module.default)(source) || (0, import_is_bun_module.isBunModule)(source, process.versions.bun ?? "latest")) {
129
- log("matched core:", source);
130
- return {
131
- found: true,
132
- path: null
133
- };
134
- }
135
- initMappers(cachedOptions);
136
- const mappedPath = getMappedPath(source, file, cachedOptions.extensions, true);
137
- if (mappedPath) {
138
- log("matched ts path:", mappedPath);
139
- }
140
- let foundNodePath;
141
- try {
142
- foundNodePath = resolver.resolveSync({}, import_node_path.default.dirname(import_node_path.default.resolve(file)), mappedPath ?? source) || null;
143
- } catch {
144
- foundNodePath = null;
145
- }
146
- if ((JS_EXT_PATTERN.test(foundNodePath) || cachedOptions.alwaysTryTypes && !foundNodePath) && !/^@types[/\\]/.test(source) && !import_node_path.default.isAbsolute(source) && !source.startsWith(".")) {
147
- const definitelyTyped = resolve("@types" + import_node_path.default.sep + mangleScopedPackage(source), file, options);
148
- if (definitelyTyped.found) {
149
- return definitelyTyped;
150
- }
151
- }
152
- if (foundNodePath) {
153
- log("matched node path:", foundNodePath);
154
- return {
155
- found: true,
156
- path: foundNodePath
157
- };
158
- }
159
- log("didn't find ", source);
160
- return {
161
- found: false
162
- };
163
- }
164
- function removeQuerystring(id) {
165
- const querystringIndex = id.lastIndexOf("?");
166
- if (querystringIndex >= 0) {
167
- return id.slice(0, querystringIndex);
168
- }
169
- return id;
170
- }
171
- var isFile = (path2) => {
172
- try {
173
- return !!(path2 && import_node_fs.default.statSync(path2, { throwIfNoEntry: false })?.isFile());
174
- } catch {
175
- return false;
176
- }
177
- };
178
- var isModule = (modulePath) => {
179
- return !!modulePath && isFile(import_node_path.default.resolve(modulePath, "package.json"));
180
- };
181
- function getMappedPath(source, file, extensions = defaultExtensions, retry) {
182
- const originalExtensions = extensions;
183
- extensions = ["", ...extensions];
184
- let paths = [];
185
- if (RELATIVE_PATH_PATTERN.test(source)) {
186
- const resolved = import_node_path.default.resolve(import_node_path.default.dirname(file), source);
187
- if (isFile(resolved)) {
188
- paths = [resolved];
189
- }
190
- } else {
191
- paths = mappers.map((mapper) => mapper?.(source).map((item) => [
192
- ...extensions.map((ext) => `${item}${ext}`),
193
- ...originalExtensions.map((ext) => `${item}/index${ext}`)
194
- ])).flat(2).filter((mappedPath) => {
195
- if (mappedPath === void 0) {
196
- return false;
197
- }
198
- try {
199
- const stat = import_node_fs.default.statSync(mappedPath, { throwIfNoEntry: false });
200
- if (stat === void 0)
201
- return false;
202
- if (stat.isFile())
203
- return true;
204
- if (stat.isDirectory()) {
205
- return isModule(mappedPath);
206
- }
207
- } catch {
208
- return false;
209
- }
210
- return false;
211
- });
212
- }
213
- if (retry && paths.length === 0) {
214
- const isJs = JS_EXT_PATTERN.test(source);
215
- if (isJs) {
216
- const jsExt = import_node_path.default.extname(source);
217
- const tsExt = jsExt.replace("js", "ts");
218
- const basename = source.replace(JS_EXT_PATTERN, "");
219
- const resolved = getMappedPath(basename + tsExt, file) || getMappedPath(basename + ".d" + (tsExt === ".tsx" ? ".ts" : tsExt), file);
220
- if (resolved) {
221
- return resolved;
222
- }
223
- }
224
- for (const ext of extensions) {
225
- const resolved = (isJs ? null : getMappedPath(source + ext, file)) || getMappedPath(source + `/index${ext}`, file);
226
- if (resolved) {
227
- return resolved;
228
- }
229
- }
230
- }
231
- if (paths.length > 1) {
232
- log("found multiple matching ts paths:", paths);
233
- }
234
- return paths[0];
235
- }
236
- function initMappers(options) {
237
- if (mappers && mappersCachedOptions === options && prevCwd === process.cwd()) {
238
- return;
239
- }
240
- prevCwd = process.cwd();
241
- const configPaths = typeof options.project === "string" ? [options.project] : Array.isArray(options.project) ? options.project : [process.cwd()];
242
- const ignore = ["!**/node_modules/**"];
243
- const projectPaths = [
244
- .../* @__PURE__ */ new Set([
245
- ...configPaths.filter((path2) => !(0, import_is_glob.default)(path2)),
246
- ...globSync([...configPaths.filter((path2) => (0, import_is_glob.default)(path2)), ...ignore])
247
- ])
248
- ];
249
- mappers = projectPaths.map((projectPath) => {
250
- let tsconfigResult;
251
- if (isFile(projectPath)) {
252
- const { dir, base } = import_node_path.default.parse(projectPath);
253
- tsconfigResult = (0, import_get_tsconfig.getTsconfig)(dir, base);
254
- } else {
255
- tsconfigResult = (0, import_get_tsconfig.getTsconfig)(projectPath);
256
- }
257
- return tsconfigResult && (0, import_get_tsconfig.createPathsMatcher)(tsconfigResult);
258
- });
259
- mappersCachedOptions = options;
260
- }
261
- function mangleScopedPackage(moduleName) {
262
- if (moduleName.startsWith("@")) {
263
- const replaceSlash = moduleName.replace(import_node_path.default.sep, "__");
264
- if (replaceSlash !== moduleName) {
265
- return replaceSlash.slice(1);
266
- }
267
- }
268
- return moduleName;
269
- }
270
- // Annotate the CommonJS export names for ESM import in node:
271
- 0 && (module.exports = {
272
- defaultConditionNames,
273
- defaultExtensionAlias,
274
- defaultExtensions,
275
- defaultMainFields,
276
- interfaceVersion,
277
- resolve
278
- });