@dloizides/frontend-devtools 1.9.0 → 2.0.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/CHANGELOG.md +162 -144
- package/README.md +10 -35
- package/dist/eslint/index.d.mts +5 -1
- package/dist/eslint/index.d.ts +5 -1
- package/dist/eslint/index.js +117 -6
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/index.mjs +112 -7
- package/dist/eslint/index.mjs.map +1 -1
- package/package.json +10 -29
- package/dist/index.d.mts +0 -69
- package/dist/index.d.ts +0 -69
- package/dist/index.js +0 -37
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -31
- package/dist/index.mjs.map +0 -1
package/dist/eslint/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import fs, { existsSync, readdirSync } from 'fs';
|
|
2
2
|
import path, { basename, dirname, sep, posix, join } from 'path';
|
|
3
|
+
import tanstackQueryPlugin from '@tanstack/eslint-plugin-query';
|
|
4
|
+
import boundariesPlugin from 'eslint-plugin-boundaries';
|
|
5
|
+
import effectPlugin from 'eslint-plugin-react-you-might-not-need-an-effect';
|
|
6
|
+
import sonarjsPlugin from 'eslint-plugin-sonarjs';
|
|
3
7
|
|
|
4
8
|
// src/rules/comment-utils.js
|
|
5
9
|
var DIRECTIVE_PATTERNS = [
|
|
@@ -2197,6 +2201,65 @@ var prefer_const_enum_default = {
|
|
|
2197
2201
|
}
|
|
2198
2202
|
};
|
|
2199
2203
|
|
|
2204
|
+
// src/rules/query-key-factory.js
|
|
2205
|
+
var QUERY_KEY = "queryKey";
|
|
2206
|
+
var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
|
|
2207
|
+
var FACTORY_FILE = /[kK]eys?(?:Factory)?\.[cm]?[jt]sx?$/;
|
|
2208
|
+
var DEFAULT_ALLOWED_PATH_FRAGMENTS2 = ["/generated/", "/autoGeneratedHooks/"];
|
|
2209
|
+
var INLINE_KEY_TYPES = /* @__PURE__ */ new Set(["ArrayExpression", "Literal", "TemplateLiteral"]);
|
|
2210
|
+
var TYPE_WRAPPERS = /* @__PURE__ */ new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression"]);
|
|
2211
|
+
function normalisePath2(filename) {
|
|
2212
|
+
return typeof filename === "string" ? filename.split("\\").join("/") : "";
|
|
2213
|
+
}
|
|
2214
|
+
function isExemptFile2(filename, allow) {
|
|
2215
|
+
const path2 = normalisePath2(filename);
|
|
2216
|
+
if (TEST_FILE2.test(path2)) return true;
|
|
2217
|
+
if (FACTORY_FILE.test(path2)) return true;
|
|
2218
|
+
return [...DEFAULT_ALLOWED_PATH_FRAGMENTS2, ...allow].some((fragment) => path2.includes(fragment));
|
|
2219
|
+
}
|
|
2220
|
+
function unwrap2(node) {
|
|
2221
|
+
let current = node;
|
|
2222
|
+
while (current && TYPE_WRAPPERS.has(current.type)) current = current.expression;
|
|
2223
|
+
return current;
|
|
2224
|
+
}
|
|
2225
|
+
function isQueryKeyProperty(node) {
|
|
2226
|
+
if (node.computed) return false;
|
|
2227
|
+
if (node.key.type === "Identifier") return node.key.name === QUERY_KEY;
|
|
2228
|
+
return node.key.type === "Literal" && node.key.value === QUERY_KEY;
|
|
2229
|
+
}
|
|
2230
|
+
var rule4 = {
|
|
2231
|
+
meta: {
|
|
2232
|
+
type: "suggestion",
|
|
2233
|
+
docs: {
|
|
2234
|
+
description: "PAT-QUERY-KEY-1: a React Query queryKey comes from a key factory, never an inline literal."
|
|
2235
|
+
},
|
|
2236
|
+
schema: [
|
|
2237
|
+
{
|
|
2238
|
+
type: "object",
|
|
2239
|
+
properties: { allow: { type: "array", items: { type: "string" } } },
|
|
2240
|
+
additionalProperties: false
|
|
2241
|
+
}
|
|
2242
|
+
],
|
|
2243
|
+
messages: {
|
|
2244
|
+
inlineKey: "Inline queryKey literal. Build it with a key factory (e.g. clientKeys.detail(id) from clientKeys.ts) so the query and its invalidation share one key."
|
|
2245
|
+
}
|
|
2246
|
+
},
|
|
2247
|
+
create(context) {
|
|
2248
|
+
const options = context.options[0] ?? {};
|
|
2249
|
+
const allow = Array.isArray(options.allow) ? options.allow : [];
|
|
2250
|
+
const filename = context.filename ?? context.getFilename();
|
|
2251
|
+
if (isExemptFile2(filename, allow)) return {};
|
|
2252
|
+
return {
|
|
2253
|
+
Property(node) {
|
|
2254
|
+
if (!isQueryKeyProperty(node)) return;
|
|
2255
|
+
const value = unwrap2(node.value);
|
|
2256
|
+
if (value && INLINE_KEY_TYPES.has(value.type)) context.report({ node: node.value, messageId: "inlineKey" });
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2261
|
+
var query_key_factory_default = { rules: { "query-key-factory": rule4 } };
|
|
2262
|
+
|
|
2200
2263
|
// src/rules/require-stable-hook-args.js
|
|
2201
2264
|
var STABLE_INIT_CALLS = /* @__PURE__ */ new Set([
|
|
2202
2265
|
"useCallback",
|
|
@@ -2880,6 +2943,7 @@ var ruleModules = [
|
|
|
2880
2943
|
no_raw_backend_fetch_default,
|
|
2881
2944
|
no_raw_color_literal_default,
|
|
2882
2945
|
prefer_const_enum_default,
|
|
2946
|
+
query_key_factory_default,
|
|
2883
2947
|
require_stable_hook_args_default,
|
|
2884
2948
|
single_row_action_source_default,
|
|
2885
2949
|
smart_max_lines_default
|
|
@@ -2887,11 +2951,11 @@ var ruleModules = [
|
|
|
2887
2951
|
function mergeRules(modules) {
|
|
2888
2952
|
const merged = {};
|
|
2889
2953
|
for (const mod of modules) {
|
|
2890
|
-
for (const [name,
|
|
2954
|
+
for (const [name, rule5] of Object.entries(mod.rules)) {
|
|
2891
2955
|
if (merged[name] !== void 0) {
|
|
2892
2956
|
throw new Error(`Duplicate ESLint rule name: "${name}"`);
|
|
2893
2957
|
}
|
|
2894
|
-
merged[name] =
|
|
2958
|
+
merged[name] = rule5;
|
|
2895
2959
|
}
|
|
2896
2960
|
}
|
|
2897
2961
|
return merged;
|
|
@@ -2907,17 +2971,58 @@ var ruleNames = Object.keys(plugin.rules).sort();
|
|
|
2907
2971
|
var legacyPlugins = buildLegacyPlugins();
|
|
2908
2972
|
function buildLegacyPlugins() {
|
|
2909
2973
|
const out = {};
|
|
2910
|
-
for (const [name,
|
|
2911
|
-
out[name] = oneRulePlugin(name,
|
|
2974
|
+
for (const [name, rule5] of Object.entries(rules)) {
|
|
2975
|
+
out[name] = oneRulePlugin(name, rule5);
|
|
2912
2976
|
}
|
|
2913
2977
|
return out;
|
|
2914
2978
|
}
|
|
2915
|
-
function oneRulePlugin(name,
|
|
2979
|
+
function oneRulePlugin(name, rule5) {
|
|
2916
2980
|
return {
|
|
2917
2981
|
meta: { name, version: "1.0.0" },
|
|
2918
|
-
rules: { [name]:
|
|
2982
|
+
rules: { [name]: rule5 }
|
|
2919
2983
|
};
|
|
2920
2984
|
}
|
|
2985
|
+
var OFF_LEVELS = ["off", 0];
|
|
2986
|
+
function pluginOf(mod) {
|
|
2987
|
+
const candidate = mod;
|
|
2988
|
+
const inner = candidate.default;
|
|
2989
|
+
return inner?.rules !== void 0 ? inner : candidate;
|
|
2990
|
+
}
|
|
2991
|
+
function rulesOf(config) {
|
|
2992
|
+
const blocks = Array.isArray(config) ? config : [config ?? {}];
|
|
2993
|
+
return Object.assign({}, ...blocks.map((block) => block.rules ?? {}));
|
|
2994
|
+
}
|
|
2995
|
+
function toWarn(entry) {
|
|
2996
|
+
const level = Array.isArray(entry) ? entry[0] : entry;
|
|
2997
|
+
if (OFF_LEVELS.includes(level)) {
|
|
2998
|
+
return entry;
|
|
2999
|
+
}
|
|
3000
|
+
return Array.isArray(entry) ? ["warn", ...entry.slice(1)] : "warn";
|
|
3001
|
+
}
|
|
3002
|
+
function warnAll(rules2) {
|
|
3003
|
+
return Object.fromEntries(Object.entries(rules2).map(([name, entry]) => [name, toWarn(entry)]));
|
|
3004
|
+
}
|
|
3005
|
+
var tanstackQuery = pluginOf(tanstackQueryPlugin);
|
|
3006
|
+
var effect = pluginOf(effectPlugin);
|
|
3007
|
+
var boundaries = pluginOf(boundariesPlugin);
|
|
3008
|
+
var sonarjs = pluginOf(sonarjsPlugin);
|
|
3009
|
+
var HOUSE_PATTERN_RULE_NAMES = ["query-key-factory"];
|
|
3010
|
+
var patternPacksConfig = {
|
|
3011
|
+
plugins: {
|
|
3012
|
+
"@tanstack/query": tanstackQuery,
|
|
3013
|
+
"react-you-might-not-need-an-effect": effect,
|
|
3014
|
+
boundaries,
|
|
3015
|
+
sonarjs,
|
|
3016
|
+
"@dloizides": plugin
|
|
3017
|
+
},
|
|
3018
|
+
rules: warnAll({
|
|
3019
|
+
...rulesOf(tanstackQuery.configs?.["flat/recommended"]),
|
|
3020
|
+
...rulesOf(effect.configs?.recommended),
|
|
3021
|
+
...rulesOf(boundaries.configs?.recommended),
|
|
3022
|
+
...rulesOf(sonarjs.configs?.recommended),
|
|
3023
|
+
"@dloizides/query-key-factory": "warn"
|
|
3024
|
+
})
|
|
3025
|
+
};
|
|
2921
3026
|
|
|
2922
3027
|
// src/eslint/configs.ts
|
|
2923
3028
|
var DOC_COMMENT_MAX_LINES = 3;
|
|
@@ -2960,6 +3065,6 @@ var recommendedConfig = {
|
|
|
2960
3065
|
rules: { ...commentsConfig.rules, ...rowActionsConfig.rules, ...apiConfig.rules }
|
|
2961
3066
|
};
|
|
2962
3067
|
|
|
2963
|
-
export { API_RULE_NAMES, COMMENT_RULE_NAMES, GAME_RULE_NAMES, ROW_ACTION_RULE_NAMES, apiConfig, commentsConfig, gameConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
|
3068
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
|
2964
3069
|
//# sourceMappingURL=index.mjs.map
|
|
2965
3070
|
//# sourceMappingURL=index.mjs.map
|