@foldkit/oxlint-plugin 0.11.0-canary.69ecbe18bcfc → 0.11.0-canary.790e96da0b63
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/all.json
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"foldkit/no-raw-dom-event-attributes": "error",
|
|
32
32
|
"foldkit/no-spread-in-evo": "error",
|
|
33
33
|
"foldkit/prefer-callable-message-constructor": "error",
|
|
34
|
+
"foldkit/prefer-effect-module-names": "error",
|
|
34
35
|
"foldkit/require-rel-for-external-link": "error",
|
|
35
36
|
"foldkit/selection-submodel-factory-at-module-scope": "error",
|
|
36
37
|
"foldkit/wrap-child-output-in-got-message": "error"
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ declare const _default: {
|
|
|
37
37
|
readonly 'no-raw-dom-event-attributes': import("effect-oxlint").CreateRule;
|
|
38
38
|
readonly 'no-spread-in-evo': import("effect-oxlint").CreateRule;
|
|
39
39
|
readonly 'prefer-callable-message-constructor': import("effect-oxlint").CreateRule;
|
|
40
|
+
readonly 'prefer-effect-module-names': import("effect-oxlint").CreateRule;
|
|
40
41
|
readonly 'require-rel-for-external-link': import("effect-oxlint").CreateRule;
|
|
41
42
|
readonly 'selection-submodel-factory-at-module-scope': import("effect-oxlint").CreateRule;
|
|
42
43
|
readonly 'wrap-child-output-in-got-message': import("effect-oxlint").CreateRule;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAqEtC,KAAK,QAAQ,GAAG,QAAQ,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;CAC3C,CAAC,CAAA;AAEF,KAAK,gBAAgB,GAAG,MAAM,CAAC,YAAY,GAAG;IAC5C,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;CAC3B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyEG,WAAW;QACX,GAAG"}
|
package/dist/index.js
CHANGED
|
@@ -13360,6 +13360,139 @@ var preferCallableMessageConstructor = Rule_exports.define({
|
|
|
13360
13360
|
}
|
|
13361
13361
|
});
|
|
13362
13362
|
|
|
13363
|
+
// src/rules/prefer-effect-module-names.ts
|
|
13364
|
+
var EFFECT_MODULE_NAME = /^[A-Z]/;
|
|
13365
|
+
var isSemanticConflictAlias = (name, localName) => localName === `Effect${name}`;
|
|
13366
|
+
var importedName2 = (specifier) => {
|
|
13367
|
+
if (isIdentifier(specifier.imported)) {
|
|
13368
|
+
return Option_exports.some(specifier.imported.name);
|
|
13369
|
+
}
|
|
13370
|
+
if (isStringLiteral(specifier.imported)) {
|
|
13371
|
+
return Option_exports.some(specifier.imported.value);
|
|
13372
|
+
}
|
|
13373
|
+
return Option_exports.none();
|
|
13374
|
+
};
|
|
13375
|
+
var importVariable = (ctx, specifier) => {
|
|
13376
|
+
const scopeManager = ctx.sourceCode.scopeManager;
|
|
13377
|
+
if (scopeManager === void 0) {
|
|
13378
|
+
return void 0;
|
|
13379
|
+
}
|
|
13380
|
+
return Array_exports.findFirst(
|
|
13381
|
+
scopeManager.getDeclaredVariables(specifier),
|
|
13382
|
+
(variable) => variable.name === specifier.local.name
|
|
13383
|
+
).pipe(Option_exports.getOrUndefined);
|
|
13384
|
+
};
|
|
13385
|
+
var hasUnshadowedReference = (ctx, name) => Array_exports.some(
|
|
13386
|
+
ctx.sourceCode.scopeManager?.scopes ?? [],
|
|
13387
|
+
(scope3) => Array_exports.some(
|
|
13388
|
+
scope3.references,
|
|
13389
|
+
(reference) => reference.identifier.name === name && (reference.resolved === null || Array_exports.isArrayEmpty(reference.resolved.defs))
|
|
13390
|
+
)
|
|
13391
|
+
);
|
|
13392
|
+
var preservesObservableName = (node) => {
|
|
13393
|
+
const parent = node.parent;
|
|
13394
|
+
if (parent === null) {
|
|
13395
|
+
return true;
|
|
13396
|
+
}
|
|
13397
|
+
if (parent.type === "Property" && parent.shorthand) {
|
|
13398
|
+
return false;
|
|
13399
|
+
}
|
|
13400
|
+
return parent.type !== "ExportSpecifier";
|
|
13401
|
+
};
|
|
13402
|
+
var hasInterveningBinding = (scope3, importScope, name) => {
|
|
13403
|
+
if (scope3 === importScope) {
|
|
13404
|
+
return false;
|
|
13405
|
+
}
|
|
13406
|
+
if (scope3.set.get(name) !== void 0 || scope3.upper === null) {
|
|
13407
|
+
return true;
|
|
13408
|
+
}
|
|
13409
|
+
return hasInterveningBinding(scope3.upper, importScope, name);
|
|
13410
|
+
};
|
|
13411
|
+
var referenceCanBeRenamed = (reference, importScope, name) => preservesObservableName(reference.identifier) && !hasInterveningBinding(reference.from, importScope, name);
|
|
13412
|
+
var aliasedEffectModule = (specifier) => {
|
|
13413
|
+
if (specifier.type !== "ImportSpecifier" || specifier.importKind === "type") {
|
|
13414
|
+
return Option_exports.none();
|
|
13415
|
+
}
|
|
13416
|
+
return Option_exports.flatMap(
|
|
13417
|
+
importedName2(specifier),
|
|
13418
|
+
(name) => EFFECT_MODULE_NAME.test(name) && specifier.local.name !== name && !isSemanticConflictAlias(name, specifier.local.name) ? Option_exports.some({ specifier, name }) : Option_exports.none()
|
|
13419
|
+
);
|
|
13420
|
+
};
|
|
13421
|
+
var importsEffectModuleAsAlias = (variable, name) => Array_exports.some(variable.defs, (definition) => {
|
|
13422
|
+
if (definition.type !== "ImportBinding" || definition.node.type !== "ImportSpecifier") {
|
|
13423
|
+
return false;
|
|
13424
|
+
}
|
|
13425
|
+
const declaration = definition.node.parent;
|
|
13426
|
+
if (declaration.type !== "ImportDeclaration" || declaration.source.value !== "effect" || declaration.importKind === "type") {
|
|
13427
|
+
return false;
|
|
13428
|
+
}
|
|
13429
|
+
return Option_exports.match(aliasedEffectModule(definition.node), {
|
|
13430
|
+
onNone: () => false,
|
|
13431
|
+
onSome: (alias) => alias.name === name
|
|
13432
|
+
});
|
|
13433
|
+
});
|
|
13434
|
+
var hasCompetingRenameTarget = (variable, name) => Array_exports.some(
|
|
13435
|
+
variable.scope.variables,
|
|
13436
|
+
(candidate) => candidate !== variable && importsEffectModuleAsAlias(candidate, name)
|
|
13437
|
+
);
|
|
13438
|
+
var canRenameBinding = (ctx, variable, name) => variable.scope.set.get(name) === void 0 && !hasUnshadowedReference(ctx, name) && !hasCompetingRenameTarget(variable, name) && Array_exports.every(
|
|
13439
|
+
variable.references,
|
|
13440
|
+
(reference) => referenceCanBeRenamed(reference, variable.scope, name)
|
|
13441
|
+
);
|
|
13442
|
+
var fixesForAlias = (ctx, { specifier, name }) => {
|
|
13443
|
+
const variable = importVariable(ctx, specifier);
|
|
13444
|
+
if (variable === void 0 || Array_exports.isArrayNonEmpty(ctx.sourceCode.getCommentsInside(specifier)) || !canRenameBinding(ctx, variable, name)) {
|
|
13445
|
+
return [];
|
|
13446
|
+
}
|
|
13447
|
+
return [
|
|
13448
|
+
Diagnostic_exports.replaceText(specifier, name),
|
|
13449
|
+
...Array_exports.map(
|
|
13450
|
+
variable.references,
|
|
13451
|
+
(reference) => Diagnostic_exports.replaceText(reference.identifier, name)
|
|
13452
|
+
)
|
|
13453
|
+
];
|
|
13454
|
+
};
|
|
13455
|
+
var preferEffectModuleNames = Rule_exports.define({
|
|
13456
|
+
name: "prefer-effect-module-names",
|
|
13457
|
+
meta: Rule_exports.meta({
|
|
13458
|
+
type: "suggestion",
|
|
13459
|
+
description: "Use Effect module names without import aliases.",
|
|
13460
|
+
fixable: "code"
|
|
13461
|
+
}),
|
|
13462
|
+
create: function* () {
|
|
13463
|
+
const ctx = yield* RuleContext;
|
|
13464
|
+
return {
|
|
13465
|
+
ImportDeclaration: (node) => {
|
|
13466
|
+
if (node.type !== "ImportDeclaration" || node.source.value !== "effect" || node.importKind === "type") {
|
|
13467
|
+
return Effect_exports.void;
|
|
13468
|
+
}
|
|
13469
|
+
const aliases = Array_exports.flatMap(
|
|
13470
|
+
node.specifiers,
|
|
13471
|
+
(specifier) => Option_exports.match(aliasedEffectModule(specifier), {
|
|
13472
|
+
onNone: () => [],
|
|
13473
|
+
onSome: (alias) => [alias]
|
|
13474
|
+
})
|
|
13475
|
+
);
|
|
13476
|
+
if (Array_exports.isReadonlyArrayEmpty(aliases)) {
|
|
13477
|
+
return Effect_exports.void;
|
|
13478
|
+
}
|
|
13479
|
+
const replacements = Array_exports.map(
|
|
13480
|
+
aliases,
|
|
13481
|
+
({ specifier, name }) => `\`${name}\` instead of \`${specifier.local.name}\``
|
|
13482
|
+
);
|
|
13483
|
+
const diagnostic = Diagnostic_exports.make({
|
|
13484
|
+
node,
|
|
13485
|
+
message: `Use Effect module names without aliases: ${replacements.join(", ")}. Qualify same-named globals through \`globalThis\`.`
|
|
13486
|
+
});
|
|
13487
|
+
const fixes = Array_exports.flatMap(aliases, (alias) => fixesForAlias(ctx, alias));
|
|
13488
|
+
return ctx.report(
|
|
13489
|
+
Array_exports.isReadonlyArrayEmpty(fixes) ? diagnostic : Diagnostic_exports.withFix(diagnostic, Diagnostic_exports.composeFixes(...fixes))
|
|
13490
|
+
);
|
|
13491
|
+
}
|
|
13492
|
+
};
|
|
13493
|
+
}
|
|
13494
|
+
});
|
|
13495
|
+
|
|
13363
13496
|
// src/rules/require-rel-for-external-link.ts
|
|
13364
13497
|
var protectiveRelSubstrings = ["noopener", "noreferrer"];
|
|
13365
13498
|
var isTargetBlankElement = (element) => {
|
|
@@ -13752,6 +13885,7 @@ var basePlugin = Plugin_exports.define({
|
|
|
13752
13885
|
"no-raw-dom-event-attributes": noRawDomEventAttributes,
|
|
13753
13886
|
"no-spread-in-evo": noSpreadInEvo,
|
|
13754
13887
|
"prefer-callable-message-constructor": preferCallableMessageConstructor,
|
|
13888
|
+
"prefer-effect-module-names": preferEffectModuleNames,
|
|
13755
13889
|
"require-rel-for-external-link": requireRelForExternalLink,
|
|
13756
13890
|
"selection-submodel-factory-at-module-scope": selectionSubmodelFactoryAtModuleScope,
|
|
13757
13891
|
"wrap-child-output-in-got-message": wrapChildOutputInGotMessage
|
|
@@ -13795,13 +13929,11 @@ var entryOverride = {
|
|
|
13795
13929
|
[decisionTimeRuleId]: "off"
|
|
13796
13930
|
}
|
|
13797
13931
|
};
|
|
13932
|
+
var rulesApplicableToTests = /* @__PURE__ */ new Set(["foldkit/prefer-effect-module-names"]);
|
|
13798
13933
|
var testOverride = (config) => ({
|
|
13799
13934
|
files: testFilePatterns,
|
|
13800
13935
|
rules: Object.fromEntries(
|
|
13801
|
-
Object.keys(config.rules).map((id) => [
|
|
13802
|
-
id,
|
|
13803
|
-
"off"
|
|
13804
|
-
])
|
|
13936
|
+
Object.keys(config.rules).filter((id) => !rulesApplicableToTests.has(id)).map((id) => [id, "off"])
|
|
13805
13937
|
)
|
|
13806
13938
|
});
|
|
13807
13939
|
var withOverrides = (config) => ({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-effect-module-names.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-effect-module-names.ts"],"names":[],"mappings":"AAyLA,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,oCAkDlC,CAAA"}
|
package/package.json
CHANGED
package/recommended.json
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"foldkit/no-raw-dom-event-attributes": "error",
|
|
32
32
|
"foldkit/no-spread-in-evo": "error",
|
|
33
33
|
"foldkit/prefer-callable-message-constructor": "error",
|
|
34
|
+
"foldkit/prefer-effect-module-names": "error",
|
|
34
35
|
"foldkit/require-rel-for-external-link": "error",
|
|
35
36
|
"foldkit/selection-submodel-factory-at-module-scope": "error",
|
|
36
37
|
"foldkit/wrap-child-output-in-got-message": "error"
|