@deslop/coding-standards 0.1.1250 → 0.1.1253
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/dist/lint.js +140 -20
- package/package.json +1 -1
package/dist/lint.js
CHANGED
|
@@ -7845,7 +7845,7 @@ const noFloatingDerivedType = defineRule({
|
|
|
7845
7845
|
});
|
|
7846
7846
|
// src/rules/no-gradient.ts
|
|
7847
7847
|
const GRADIENT = /(?:^|[\s:])bg-(?:linear|radial|conic|gradient)(?:-|$|\s)|gradient\(/u;
|
|
7848
|
-
function report$
|
|
7848
|
+
function report$6(context, node) {
|
|
7849
7849
|
context.report({
|
|
7850
7850
|
message: "Use a flat theme token such as bg-card or bg-muted; gradients are never part of the design.",
|
|
7851
7851
|
node
|
|
@@ -7854,10 +7854,10 @@ function report$5(context, node) {
|
|
|
7854
7854
|
const noGradient = defineRule({
|
|
7855
7855
|
create: (context) => ({
|
|
7856
7856
|
Literal: (node) => {
|
|
7857
|
-
if (isString(node.value) && GRADIENT.test(node.value)) report$
|
|
7857
|
+
if (isString(node.value) && GRADIENT.test(node.value)) report$6(context, node);
|
|
7858
7858
|
},
|
|
7859
7859
|
TemplateElement: (node) => {
|
|
7860
|
-
if (GRADIENT.test(node.value.raw)) report$
|
|
7860
|
+
if (GRADIENT.test(node.value.raw)) report$6(context, node);
|
|
7861
7861
|
}
|
|
7862
7862
|
}),
|
|
7863
7863
|
meta: { type: "problem" }
|
|
@@ -7945,7 +7945,7 @@ function replaceableGuard(node) {
|
|
|
7945
7945
|
"typeof === undefined": "isUndefined"
|
|
7946
7946
|
}, key)));
|
|
7947
7947
|
}
|
|
7948
|
-
function report$
|
|
7948
|
+
function report$5(input) {
|
|
7949
7949
|
map$1(replaceableGuard(input.node), (guard) => input.context.report({
|
|
7950
7950
|
message: `Use Predicate.${guard} instead of this hand-written type guard.`,
|
|
7951
7951
|
node: input.node
|
|
@@ -7954,19 +7954,19 @@ function report$4(input) {
|
|
|
7954
7954
|
const noHandWrittenGuard = defineRule({
|
|
7955
7955
|
create: (context) => ({
|
|
7956
7956
|
ArrowFunctionExpression: (node) => {
|
|
7957
|
-
report$
|
|
7957
|
+
report$5({
|
|
7958
7958
|
context,
|
|
7959
7959
|
node
|
|
7960
7960
|
});
|
|
7961
7961
|
},
|
|
7962
7962
|
FunctionDeclaration: (node) => {
|
|
7963
|
-
report$
|
|
7963
|
+
report$5({
|
|
7964
7964
|
context,
|
|
7965
7965
|
node
|
|
7966
7966
|
});
|
|
7967
7967
|
},
|
|
7968
7968
|
FunctionExpression: (node) => {
|
|
7969
|
-
report$
|
|
7969
|
+
report$5({
|
|
7970
7970
|
context,
|
|
7971
7971
|
node
|
|
7972
7972
|
});
|
|
@@ -8687,7 +8687,7 @@ function replacement(input) {
|
|
|
8687
8687
|
if (input.read.parent?.type === "Property" && input.read.parent.shorthand) return `${input.name}: ${input.text}`;
|
|
8688
8688
|
return input.text;
|
|
8689
8689
|
}
|
|
8690
|
-
function report$
|
|
8690
|
+
function report$4(input) {
|
|
8691
8691
|
const reads = pipe(input.variable.references, filter((reference) => reference.isRead()), map((reference) => reference.identifier));
|
|
8692
8692
|
const text = input.context.sourceCode.getText(input.init);
|
|
8693
8693
|
const aliasRequired = needsAlias({
|
|
@@ -8766,7 +8766,7 @@ const noPropertyAlias = defineRule({
|
|
|
8766
8766
|
scope: context.sourceCode.getScope(candidate.node)
|
|
8767
8767
|
}), match$2({
|
|
8768
8768
|
onNone: constVoid,
|
|
8769
|
-
onSome: (variable) => report$
|
|
8769
|
+
onSome: (variable) => report$4({
|
|
8770
8770
|
...candidate,
|
|
8771
8771
|
context,
|
|
8772
8772
|
variable,
|
|
@@ -8962,7 +8962,7 @@ const shipped = [
|
|
|
8962
8962
|
schema: "Natural"
|
|
8963
8963
|
}
|
|
8964
8964
|
];
|
|
8965
|
-
function schemaMember$
|
|
8965
|
+
function schemaMember$2(input) {
|
|
8966
8966
|
if (input.node.type !== "MemberExpression" || !importedMember({
|
|
8967
8967
|
context: input.context,
|
|
8968
8968
|
importedName: "Schema",
|
|
@@ -8972,11 +8972,11 @@ function schemaMember$1(input) {
|
|
|
8972
8972
|
}
|
|
8973
8973
|
function shippedSchema(input) {
|
|
8974
8974
|
if (input.filter.type !== "CallExpression") return none();
|
|
8975
|
-
const base = schemaMember$
|
|
8975
|
+
const base = schemaMember$2({
|
|
8976
8976
|
context: input.context,
|
|
8977
8977
|
node: input.base
|
|
8978
8978
|
});
|
|
8979
|
-
const check = schemaMember$
|
|
8979
|
+
const check = schemaMember$2({
|
|
8980
8980
|
context: input.context,
|
|
8981
8981
|
node: input.filter.callee
|
|
8982
8982
|
});
|
|
@@ -8999,7 +8999,7 @@ function reinventedSchema(input) {
|
|
|
8999
8999
|
if (input.node.callee.type !== "MemberExpression" || !contains$1(memberName(input.node.callee), "check")) return none();
|
|
9000
9000
|
const callee = input.node.callee;
|
|
9001
9001
|
const [filter] = input.node.arguments;
|
|
9002
|
-
if (isSome(schemaMember$
|
|
9002
|
+
if (isSome(schemaMember$2({
|
|
9003
9003
|
context: input.context,
|
|
9004
9004
|
node: callee
|
|
9005
9005
|
}))) {
|
|
@@ -9562,7 +9562,7 @@ function executes(context, node) {
|
|
|
9562
9562
|
function receiver(read) {
|
|
9563
9563
|
return read.parent?.type === "MemberExpression" && read.parent.object === read && read.parent.parent.type === "CallExpression" && read.parent.parent.callee === read.parent;
|
|
9564
9564
|
}
|
|
9565
|
-
function report$
|
|
9565
|
+
function report$3(input) {
|
|
9566
9566
|
const declaration = input.node.parent;
|
|
9567
9567
|
const init = input.node.init;
|
|
9568
9568
|
if (declaration.type !== "VariableDeclaration" || declaration.parent.type !== "BlockStatement" || input.node.id.type !== "Identifier" || init === null) return;
|
|
@@ -9619,7 +9619,7 @@ const noSingleUseValue = defineRule({
|
|
|
9619
9619
|
NewExpression: effect,
|
|
9620
9620
|
"Program:exit": () => {
|
|
9621
9621
|
const nodes = toArray(effects);
|
|
9622
|
-
for (const node of toArray(candidates)) report$
|
|
9622
|
+
for (const node of toArray(candidates)) report$3({
|
|
9623
9623
|
context,
|
|
9624
9624
|
effects: nodes,
|
|
9625
9625
|
node
|
|
@@ -9926,7 +9926,7 @@ const noTestTimeout = defineRule({
|
|
|
9926
9926
|
meta: { type: "problem" }
|
|
9927
9927
|
});
|
|
9928
9928
|
// src/rules/no-type-from-value.ts
|
|
9929
|
-
function schemaMember(name) {
|
|
9929
|
+
function schemaMember$1(name) {
|
|
9930
9930
|
return name.type === "TSQualifiedName" && contains([
|
|
9931
9931
|
"Encoded",
|
|
9932
9932
|
"Type",
|
|
@@ -9939,7 +9939,7 @@ function schemaMember(name) {
|
|
|
9939
9939
|
function valueQuery(node) {
|
|
9940
9940
|
if (node.type === "TSParenthesizedType") return valueQuery(node.typeAnnotation);
|
|
9941
9941
|
if (node.type === "TSIndexedAccessType") return valueQuery(node.objectType);
|
|
9942
|
-
return node.type === "TSTypeQuery" && (node.exprName.type === "Identifier" || node.exprName.type === "TSQualifiedName" && !schemaMember(node.exprName));
|
|
9942
|
+
return node.type === "TSTypeQuery" && (node.exprName.type === "Identifier" || node.exprName.type === "TSQualifiedName" && !schemaMember$1(node.exprName));
|
|
9943
9943
|
}
|
|
9944
9944
|
function nestedObject(node) {
|
|
9945
9945
|
return node.parent?.type === "TSIndexedAccessType" && node.parent.objectType === node;
|
|
@@ -10288,7 +10288,7 @@ function fix(input) {
|
|
|
10288
10288
|
return some$1([input.fixer.replaceTextRange([open.range[0], close.range[1]], "(cause)"), insertion]);
|
|
10289
10289
|
}), () => []);
|
|
10290
10290
|
}
|
|
10291
|
-
function report$
|
|
10291
|
+
function report$2(context, node) {
|
|
10292
10292
|
context.report({
|
|
10293
10293
|
fix: (fixer) => fix({
|
|
10294
10294
|
context,
|
|
@@ -10301,7 +10301,7 @@ function report$1(context, node) {
|
|
|
10301
10301
|
}
|
|
10302
10302
|
function reportOption(context, key, bare, options) {
|
|
10303
10303
|
if (options?.type !== "ObjectExpression") return;
|
|
10304
|
-
for (const property of options.properties) if (property.type === "Property" && property.key.type === "Identifier" && property.key.name === key && dropsCause(context, property.value, bare)) report$
|
|
10304
|
+
for (const property of options.properties) if (property.type === "Property" && property.key.type === "Identifier" && property.key.name === key && dropsCause(context, property.value, bare)) report$2(context, property.value);
|
|
10305
10305
|
}
|
|
10306
10306
|
const preserveErrorCause = defineRule({
|
|
10307
10307
|
create: (context) => ({ CallExpression: (node) => {
|
|
@@ -10311,7 +10311,7 @@ const preserveErrorCause = defineRule({
|
|
|
10311
10311
|
});
|
|
10312
10312
|
if (contains$1(name, "mapError")) {
|
|
10313
10313
|
const bare = detailedFailure(context, node);
|
|
10314
|
-
forEach(filter(node.arguments, (argument) => dropsCause(context, argument, bare)), (callback) => report$
|
|
10314
|
+
forEach(filter(node.arguments, (argument) => dropsCause(context, argument, bare)), (callback) => report$2(context, callback));
|
|
10315
10315
|
return;
|
|
10316
10316
|
}
|
|
10317
10317
|
if (contains$1(name, "mapBoth")) {
|
|
@@ -10562,6 +10562,125 @@ const schemaTypePair = defineRule({
|
|
|
10562
10562
|
type: "problem"
|
|
10563
10563
|
}
|
|
10564
10564
|
});
|
|
10565
|
+
// src/rules/service-schema-file.ts
|
|
10566
|
+
const SERVICE_PATH = /[/\\]src[/\\]services[/\\][^/\\]+[/\\]/u;
|
|
10567
|
+
const SCHEMA_FILE = /[/\\]schema\.ts$/u;
|
|
10568
|
+
const SCHEMA_CLASSES = [
|
|
10569
|
+
"Class",
|
|
10570
|
+
"TaggedClass",
|
|
10571
|
+
"TaggedError",
|
|
10572
|
+
"TaggedRequest"
|
|
10573
|
+
];
|
|
10574
|
+
const DERIVED = matches(/^(?:is|to)[A-Z]/u);
|
|
10575
|
+
const FILTER = matches(/^makeFilter(?:Group)?$/u);
|
|
10576
|
+
function schemaMember(input) {
|
|
10577
|
+
if (input.node.type === "CallExpression" && input.node.callee.type !== "Super") return schemaMember({
|
|
10578
|
+
context: input.context,
|
|
10579
|
+
node: input.node.callee
|
|
10580
|
+
});
|
|
10581
|
+
if (input.node.type === "ChainExpression") return schemaMember({
|
|
10582
|
+
context: input.context,
|
|
10583
|
+
node: input.node.expression
|
|
10584
|
+
});
|
|
10585
|
+
if (input.node.type === "TSInstantiationExpression") return schemaMember({
|
|
10586
|
+
context: input.context,
|
|
10587
|
+
node: input.node.expression
|
|
10588
|
+
});
|
|
10589
|
+
if (input.node.type === "TSSatisfiesExpression") return schemaMember({
|
|
10590
|
+
context: input.context,
|
|
10591
|
+
node: input.node.expression
|
|
10592
|
+
});
|
|
10593
|
+
if (input.node.type === "MemberExpression") {
|
|
10594
|
+
if (input.node.object.type === "Identifier") return some$1(input.node);
|
|
10595
|
+
if (input.node.object.type !== "Super") return schemaMember({
|
|
10596
|
+
context: input.context,
|
|
10597
|
+
node: input.node.object
|
|
10598
|
+
});
|
|
10599
|
+
}
|
|
10600
|
+
return none();
|
|
10601
|
+
}
|
|
10602
|
+
function constructorMember(input) {
|
|
10603
|
+
return importedMember({
|
|
10604
|
+
context: input.context,
|
|
10605
|
+
importedName: "Schema",
|
|
10606
|
+
node: input.node
|
|
10607
|
+
}) && pipe(memberName(input.node), exists((name) => !isSchemaOperationName(name) && !DERIVED(name) && !FILTER(name)));
|
|
10608
|
+
}
|
|
10609
|
+
function definesSchema(input) {
|
|
10610
|
+
if (input.node.type === "CallExpression" && input.node.callee.type === "Identifier" && isImportBinding({
|
|
10611
|
+
context: input.context,
|
|
10612
|
+
importedName: "pipe",
|
|
10613
|
+
node: input.node.callee,
|
|
10614
|
+
source: "effect"
|
|
10615
|
+
})) {
|
|
10616
|
+
const [first] = input.node.arguments;
|
|
10617
|
+
return first !== void 0 && first.type !== "SpreadElement" && definesSchema({
|
|
10618
|
+
...input,
|
|
10619
|
+
node: first
|
|
10620
|
+
});
|
|
10621
|
+
}
|
|
10622
|
+
return pipe(schemaMember(input), exists((member) => constructorMember({
|
|
10623
|
+
context: input.context,
|
|
10624
|
+
node: member
|
|
10625
|
+
})));
|
|
10626
|
+
}
|
|
10627
|
+
function schemaClass(input) {
|
|
10628
|
+
if (input.node.type === "CallExpression" && input.node.callee.type !== "Super") return schemaClass({
|
|
10629
|
+
context: input.context,
|
|
10630
|
+
node: input.node.callee
|
|
10631
|
+
});
|
|
10632
|
+
if (input.node.type === "TSInstantiationExpression") return schemaClass({
|
|
10633
|
+
context: input.context,
|
|
10634
|
+
node: input.node.expression
|
|
10635
|
+
});
|
|
10636
|
+
if (input.node.type === "MemberExpression" && input.node.object.type === "Identifier" && importedMember({
|
|
10637
|
+
context: input.context,
|
|
10638
|
+
importedName: "Schema",
|
|
10639
|
+
node: input.node
|
|
10640
|
+
})) return pipe(memberName(input.node), exists((name) => contains(SCHEMA_CLASSES, name)));
|
|
10641
|
+
return false;
|
|
10642
|
+
}
|
|
10643
|
+
function extendsSchema(input) {
|
|
10644
|
+
return input.node.superClass !== null && schemaClass({
|
|
10645
|
+
context: input.context,
|
|
10646
|
+
node: input.node.superClass
|
|
10647
|
+
});
|
|
10648
|
+
}
|
|
10649
|
+
function report$1(context, node) {
|
|
10650
|
+
context.report({
|
|
10651
|
+
message: "Move this schema into the service's schema.ts and import it.",
|
|
10652
|
+
node
|
|
10653
|
+
});
|
|
10654
|
+
}
|
|
10655
|
+
function exported(statement) {
|
|
10656
|
+
if (statement.type === "ExportDefaultDeclaration") return statement.declaration;
|
|
10657
|
+
return statementDeclaration(statement);
|
|
10658
|
+
}
|
|
10659
|
+
function definitions(context, declaration) {
|
|
10660
|
+
if (declaration?.type === "VariableDeclaration" && declaration.kind === "const") return flatMap(declaration.declarations, (variable) => {
|
|
10661
|
+
if (variable.init === null) return empty$2();
|
|
10662
|
+
if (variable.init.type === "ClassExpression") return filter([variable.init], (node) => extendsSchema({
|
|
10663
|
+
context,
|
|
10664
|
+
node
|
|
10665
|
+
}));
|
|
10666
|
+
return filter([variable.init], (node) => definesSchema({
|
|
10667
|
+
context,
|
|
10668
|
+
node
|
|
10669
|
+
}));
|
|
10670
|
+
});
|
|
10671
|
+
if (declaration?.type === "ClassDeclaration" || declaration?.type === "ClassExpression") return filter([declaration], (node) => extendsSchema({
|
|
10672
|
+
context,
|
|
10673
|
+
node
|
|
10674
|
+
}));
|
|
10675
|
+
return empty$2();
|
|
10676
|
+
}
|
|
10677
|
+
const serviceSchemaFile = defineRule({
|
|
10678
|
+
create: (context) => ({ Program: (program) => {
|
|
10679
|
+
if (!SERVICE_PATH.test(context.filename) || SCHEMA_FILE.test(context.filename) || isTestFile(context)) return;
|
|
10680
|
+
for (const node of flatMap(program.body, (statement) => definitions(context, exported(statement)))) report$1(context, node);
|
|
10681
|
+
} }),
|
|
10682
|
+
meta: { type: "problem" }
|
|
10683
|
+
});
|
|
10565
10684
|
// src/rules/swiftui-theme-values.ts
|
|
10566
10685
|
const PAINTS = [
|
|
10567
10686
|
"background",
|
|
@@ -10723,6 +10842,7 @@ const RULES = {
|
|
|
10723
10842
|
"preserve-error-cause": preserveErrorCause,
|
|
10724
10843
|
"require-unicode-regexp": requireUnicodeRegexp,
|
|
10725
10844
|
"schema-type-pair": schemaTypePair,
|
|
10845
|
+
"service-schema-file": serviceSchemaFile,
|
|
10726
10846
|
"swiftui-theme-values": swiftuiThemeValues
|
|
10727
10847
|
};
|
|
10728
10848
|
const lint = {
|