@dloizides/frontend-devtools 1.9.0 → 1.10.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 +9 -0
- 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 +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to `@dloizides/frontend-devtools` are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.10.0] - 2026-10-19
|
|
9
|
+
|
|
10
|
+
PATTERN-1.12 "TS rule packs + house rules in frontend-devtools" (D-PAT-12 "Whole rule packs as warnings, one shared approach").
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `patternPacksConfig`: the recommended rules of `@tanstack/eslint-plugin-query`, `eslint-plugin-react-you-might-not-need-an-effect`, `eslint-plugin-boundaries` and `eslint-plugin-sonarjs`, every rule at `warn`, plus the house rules.
|
|
14
|
+
- `query-key-factory` (PAT-QUERY-KEY-1 "queryKey only from a key factory"): flags an inline array/string/template `queryKey`; key-factory files (`*Keys.ts`), tests and generated code are exempt; `allow` adds path fragments.
|
|
15
|
+
- `HOUSE_PATTERN_RULE_NAMES`.
|
|
16
|
+
|
|
8
17
|
## [1.9.0] - 2026-10-19
|
|
9
18
|
|
|
10
19
|
PATTERN-1.4 "TypeScript pattern rules as ESLint rules", `no-raw-backend-fetch` (PAT-API-1 "web apps call the backend through the shared client") hardening.
|
package/dist/eslint/index.d.mts
CHANGED
|
@@ -74,6 +74,10 @@ declare const ruleNames: readonly string[];
|
|
|
74
74
|
*/
|
|
75
75
|
declare const legacyPlugins: Record<string, FlatConfigPlugin>;
|
|
76
76
|
|
|
77
|
+
declare const HOUSE_PATTERN_RULE_NAMES: readonly string[];
|
|
78
|
+
/** D-PAT-12 preset: four community rule packs plus the house pattern rules, every rule at warn. */
|
|
79
|
+
declare const patternPacksConfig: FlatConfig;
|
|
80
|
+
|
|
77
81
|
declare const COMMENT_RULE_NAMES: readonly string[];
|
|
78
82
|
/** Flat-config block for COMMENTS-1: no code comments, short doc comments on public members only. */
|
|
79
83
|
declare const commentsConfig: FlatConfig;
|
|
@@ -89,4 +93,4 @@ declare const apiConfig: FlatConfig;
|
|
|
89
93
|
/** The recommended flat-config block: every rule the pack enables by default, at error. */
|
|
90
94
|
declare const recommendedConfig: FlatConfig;
|
|
91
95
|
|
|
92
|
-
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
|
96
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -74,6 +74,10 @@ declare const ruleNames: readonly string[];
|
|
|
74
74
|
*/
|
|
75
75
|
declare const legacyPlugins: Record<string, FlatConfigPlugin>;
|
|
76
76
|
|
|
77
|
+
declare const HOUSE_PATTERN_RULE_NAMES: readonly string[];
|
|
78
|
+
/** D-PAT-12 preset: four community rule packs plus the house pattern rules, every rule at warn. */
|
|
79
|
+
declare const patternPacksConfig: FlatConfig;
|
|
80
|
+
|
|
77
81
|
declare const COMMENT_RULE_NAMES: readonly string[];
|
|
78
82
|
/** Flat-config block for COMMENTS-1: no code comments, short doc comments on public members only. */
|
|
79
83
|
declare const commentsConfig: FlatConfig;
|
|
@@ -89,4 +93,4 @@ declare const apiConfig: FlatConfig;
|
|
|
89
93
|
/** The recommended flat-config block: every rule the pack enables by default, at error. */
|
|
90
94
|
declare const recommendedConfig: FlatConfig;
|
|
91
95
|
|
|
92
|
-
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
|
96
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
package/dist/eslint/index.js
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('fs');
|
|
4
4
|
var path = require('path');
|
|
5
|
+
var tanstackQueryPlugin = require('@tanstack/eslint-plugin-query');
|
|
6
|
+
var boundariesPlugin = require('eslint-plugin-boundaries');
|
|
7
|
+
var effectPlugin = require('eslint-plugin-react-you-might-not-need-an-effect');
|
|
8
|
+
var sonarjsPlugin = require('eslint-plugin-sonarjs');
|
|
5
9
|
|
|
6
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
11
|
|
|
8
12
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
9
13
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
14
|
+
var tanstackQueryPlugin__default = /*#__PURE__*/_interopDefault(tanstackQueryPlugin);
|
|
15
|
+
var boundariesPlugin__default = /*#__PURE__*/_interopDefault(boundariesPlugin);
|
|
16
|
+
var effectPlugin__default = /*#__PURE__*/_interopDefault(effectPlugin);
|
|
17
|
+
var sonarjsPlugin__default = /*#__PURE__*/_interopDefault(sonarjsPlugin);
|
|
10
18
|
|
|
11
19
|
// src/rules/comment-utils.js
|
|
12
20
|
var DIRECTIVE_PATTERNS = [
|
|
@@ -2204,6 +2212,65 @@ var prefer_const_enum_default = {
|
|
|
2204
2212
|
}
|
|
2205
2213
|
};
|
|
2206
2214
|
|
|
2215
|
+
// src/rules/query-key-factory.js
|
|
2216
|
+
var QUERY_KEY = "queryKey";
|
|
2217
|
+
var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
|
|
2218
|
+
var FACTORY_FILE = /[kK]eys?(?:Factory)?\.[cm]?[jt]sx?$/;
|
|
2219
|
+
var DEFAULT_ALLOWED_PATH_FRAGMENTS2 = ["/generated/", "/autoGeneratedHooks/"];
|
|
2220
|
+
var INLINE_KEY_TYPES = /* @__PURE__ */ new Set(["ArrayExpression", "Literal", "TemplateLiteral"]);
|
|
2221
|
+
var TYPE_WRAPPERS = /* @__PURE__ */ new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression"]);
|
|
2222
|
+
function normalisePath2(filename) {
|
|
2223
|
+
return typeof filename === "string" ? filename.split("\\").join("/") : "";
|
|
2224
|
+
}
|
|
2225
|
+
function isExemptFile2(filename, allow) {
|
|
2226
|
+
const path2 = normalisePath2(filename);
|
|
2227
|
+
if (TEST_FILE2.test(path2)) return true;
|
|
2228
|
+
if (FACTORY_FILE.test(path2)) return true;
|
|
2229
|
+
return [...DEFAULT_ALLOWED_PATH_FRAGMENTS2, ...allow].some((fragment) => path2.includes(fragment));
|
|
2230
|
+
}
|
|
2231
|
+
function unwrap2(node) {
|
|
2232
|
+
let current = node;
|
|
2233
|
+
while (current && TYPE_WRAPPERS.has(current.type)) current = current.expression;
|
|
2234
|
+
return current;
|
|
2235
|
+
}
|
|
2236
|
+
function isQueryKeyProperty(node) {
|
|
2237
|
+
if (node.computed) return false;
|
|
2238
|
+
if (node.key.type === "Identifier") return node.key.name === QUERY_KEY;
|
|
2239
|
+
return node.key.type === "Literal" && node.key.value === QUERY_KEY;
|
|
2240
|
+
}
|
|
2241
|
+
var rule4 = {
|
|
2242
|
+
meta: {
|
|
2243
|
+
type: "suggestion",
|
|
2244
|
+
docs: {
|
|
2245
|
+
description: "PAT-QUERY-KEY-1: a React Query queryKey comes from a key factory, never an inline literal."
|
|
2246
|
+
},
|
|
2247
|
+
schema: [
|
|
2248
|
+
{
|
|
2249
|
+
type: "object",
|
|
2250
|
+
properties: { allow: { type: "array", items: { type: "string" } } },
|
|
2251
|
+
additionalProperties: false
|
|
2252
|
+
}
|
|
2253
|
+
],
|
|
2254
|
+
messages: {
|
|
2255
|
+
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."
|
|
2256
|
+
}
|
|
2257
|
+
},
|
|
2258
|
+
create(context) {
|
|
2259
|
+
const options = context.options[0] ?? {};
|
|
2260
|
+
const allow = Array.isArray(options.allow) ? options.allow : [];
|
|
2261
|
+
const filename = context.filename ?? context.getFilename();
|
|
2262
|
+
if (isExemptFile2(filename, allow)) return {};
|
|
2263
|
+
return {
|
|
2264
|
+
Property(node) {
|
|
2265
|
+
if (!isQueryKeyProperty(node)) return;
|
|
2266
|
+
const value = unwrap2(node.value);
|
|
2267
|
+
if (value && INLINE_KEY_TYPES.has(value.type)) context.report({ node: node.value, messageId: "inlineKey" });
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
var query_key_factory_default = { rules: { "query-key-factory": rule4 } };
|
|
2273
|
+
|
|
2207
2274
|
// src/rules/require-stable-hook-args.js
|
|
2208
2275
|
var STABLE_INIT_CALLS = /* @__PURE__ */ new Set([
|
|
2209
2276
|
"useCallback",
|
|
@@ -2887,6 +2954,7 @@ var ruleModules = [
|
|
|
2887
2954
|
no_raw_backend_fetch_default,
|
|
2888
2955
|
no_raw_color_literal_default,
|
|
2889
2956
|
prefer_const_enum_default,
|
|
2957
|
+
query_key_factory_default,
|
|
2890
2958
|
require_stable_hook_args_default,
|
|
2891
2959
|
single_row_action_source_default,
|
|
2892
2960
|
smart_max_lines_default
|
|
@@ -2894,11 +2962,11 @@ var ruleModules = [
|
|
|
2894
2962
|
function mergeRules(modules) {
|
|
2895
2963
|
const merged = {};
|
|
2896
2964
|
for (const mod of modules) {
|
|
2897
|
-
for (const [name,
|
|
2965
|
+
for (const [name, rule5] of Object.entries(mod.rules)) {
|
|
2898
2966
|
if (merged[name] !== void 0) {
|
|
2899
2967
|
throw new Error(`Duplicate ESLint rule name: "${name}"`);
|
|
2900
2968
|
}
|
|
2901
|
-
merged[name] =
|
|
2969
|
+
merged[name] = rule5;
|
|
2902
2970
|
}
|
|
2903
2971
|
}
|
|
2904
2972
|
return merged;
|
|
@@ -2914,17 +2982,58 @@ var ruleNames = Object.keys(plugin.rules).sort();
|
|
|
2914
2982
|
var legacyPlugins = buildLegacyPlugins();
|
|
2915
2983
|
function buildLegacyPlugins() {
|
|
2916
2984
|
const out = {};
|
|
2917
|
-
for (const [name,
|
|
2918
|
-
out[name] = oneRulePlugin(name,
|
|
2985
|
+
for (const [name, rule5] of Object.entries(rules)) {
|
|
2986
|
+
out[name] = oneRulePlugin(name, rule5);
|
|
2919
2987
|
}
|
|
2920
2988
|
return out;
|
|
2921
2989
|
}
|
|
2922
|
-
function oneRulePlugin(name,
|
|
2990
|
+
function oneRulePlugin(name, rule5) {
|
|
2923
2991
|
return {
|
|
2924
2992
|
meta: { name, version: "1.0.0" },
|
|
2925
|
-
rules: { [name]:
|
|
2993
|
+
rules: { [name]: rule5 }
|
|
2926
2994
|
};
|
|
2927
2995
|
}
|
|
2996
|
+
var OFF_LEVELS = ["off", 0];
|
|
2997
|
+
function pluginOf(mod) {
|
|
2998
|
+
const candidate = mod;
|
|
2999
|
+
const inner = candidate.default;
|
|
3000
|
+
return inner?.rules !== void 0 ? inner : candidate;
|
|
3001
|
+
}
|
|
3002
|
+
function rulesOf(config) {
|
|
3003
|
+
const blocks = Array.isArray(config) ? config : [config ?? {}];
|
|
3004
|
+
return Object.assign({}, ...blocks.map((block) => block.rules ?? {}));
|
|
3005
|
+
}
|
|
3006
|
+
function toWarn(entry) {
|
|
3007
|
+
const level = Array.isArray(entry) ? entry[0] : entry;
|
|
3008
|
+
if (OFF_LEVELS.includes(level)) {
|
|
3009
|
+
return entry;
|
|
3010
|
+
}
|
|
3011
|
+
return Array.isArray(entry) ? ["warn", ...entry.slice(1)] : "warn";
|
|
3012
|
+
}
|
|
3013
|
+
function warnAll(rules2) {
|
|
3014
|
+
return Object.fromEntries(Object.entries(rules2).map(([name, entry]) => [name, toWarn(entry)]));
|
|
3015
|
+
}
|
|
3016
|
+
var tanstackQuery = pluginOf(tanstackQueryPlugin__default.default);
|
|
3017
|
+
var effect = pluginOf(effectPlugin__default.default);
|
|
3018
|
+
var boundaries = pluginOf(boundariesPlugin__default.default);
|
|
3019
|
+
var sonarjs = pluginOf(sonarjsPlugin__default.default);
|
|
3020
|
+
var HOUSE_PATTERN_RULE_NAMES = ["query-key-factory"];
|
|
3021
|
+
var patternPacksConfig = {
|
|
3022
|
+
plugins: {
|
|
3023
|
+
"@tanstack/query": tanstackQuery,
|
|
3024
|
+
"react-you-might-not-need-an-effect": effect,
|
|
3025
|
+
boundaries,
|
|
3026
|
+
sonarjs,
|
|
3027
|
+
"@dloizides": plugin
|
|
3028
|
+
},
|
|
3029
|
+
rules: warnAll({
|
|
3030
|
+
...rulesOf(tanstackQuery.configs?.["flat/recommended"]),
|
|
3031
|
+
...rulesOf(effect.configs?.recommended),
|
|
3032
|
+
...rulesOf(boundaries.configs?.recommended),
|
|
3033
|
+
...rulesOf(sonarjs.configs?.recommended),
|
|
3034
|
+
"@dloizides/query-key-factory": "warn"
|
|
3035
|
+
})
|
|
3036
|
+
};
|
|
2928
3037
|
|
|
2929
3038
|
// src/eslint/configs.ts
|
|
2930
3039
|
var DOC_COMMENT_MAX_LINES = 3;
|
|
@@ -2970,11 +3079,13 @@ var recommendedConfig = {
|
|
|
2970
3079
|
exports.API_RULE_NAMES = API_RULE_NAMES;
|
|
2971
3080
|
exports.COMMENT_RULE_NAMES = COMMENT_RULE_NAMES;
|
|
2972
3081
|
exports.GAME_RULE_NAMES = GAME_RULE_NAMES;
|
|
3082
|
+
exports.HOUSE_PATTERN_RULE_NAMES = HOUSE_PATTERN_RULE_NAMES;
|
|
2973
3083
|
exports.ROW_ACTION_RULE_NAMES = ROW_ACTION_RULE_NAMES;
|
|
2974
3084
|
exports.apiConfig = apiConfig;
|
|
2975
3085
|
exports.commentsConfig = commentsConfig;
|
|
2976
3086
|
exports.gameConfig = gameConfig;
|
|
2977
3087
|
exports.legacyPlugins = legacyPlugins;
|
|
3088
|
+
exports.patternPacksConfig = patternPacksConfig;
|
|
2978
3089
|
exports.plugin = plugin;
|
|
2979
3090
|
exports.recommendedConfig = recommendedConfig;
|
|
2980
3091
|
exports.rowActionsConfig = rowActionsConfig;
|