@azure-tools/typespec-azure-core 0.41.0-dev.3 → 0.41.0-dev.4

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/README.md CHANGED
@@ -56,7 +56,7 @@ Available ruleSets:
56
56
  | `@azure-tools/typespec-azure-core/no-multiple-discriminator` | Classes should have at most one discriminator. |
57
57
  | `@azure-tools/typespec-azure-core/no-rest-library-interfaces` | Resource interfaces from the TypeSpec.Rest.Resource library are incompatible with Azure.Core. |
58
58
  | `@azure-tools/typespec-azure-core/no-unknown` | Azure services must not have properties of type `unknown`. |
59
- | `@azure-tools/typespec-azure-core/property-name-conflict` | Avoid naming conflicts. |
59
+ | `@azure-tools/typespec-azure-core/property-name-conflict` | Avoid naming conflicts between a property and a model of the same name. |
60
60
  | `@azure-tools/typespec-azure-core/bad-record-type` | Identify bad record definitions. |
61
61
  | `@azure-tools/typespec-azure-core/documentation-required` | Require documentation over enums, models, and operations. |
62
62
  | `@azure-tools/typespec-azure-core/key-visibility-required` | Key properties need to have an explicit visibility setting. |
@@ -1,5 +1,4 @@
1
1
  export declare const propertyNameRule: import("@typespec/compiler").LinterRuleDefinition<"property-name-conflict", {
2
2
  readonly default: import("@typespec/compiler").CallableMessage<[string]>;
3
- readonly projectedName: import("@typespec/compiler").CallableMessage<[string, string]>;
4
3
  }>;
5
4
  //# sourceMappingURL=property-naming.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"property-naming.d.ts","sourceRoot":"","sources":["../../../src/rules/property-naming.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;EAoC3B,CAAC"}
1
+ {"version":3,"file":"property-naming.d.ts","sourceRoot":"","sources":["../../../src/rules/property-naming.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;EAsB3B,CAAC"}
@@ -1,35 +1,21 @@
1
- import { createRule, getProjectedNames, paramMessage } from "@typespec/compiler";
1
+ import { createRule, paramMessage } from "@typespec/compiler";
2
2
  import { isExcludedCoreType } from "./utils.js";
3
3
  export const propertyNameRule = createRule({
4
4
  name: "property-name-conflict",
5
- description: "Avoid naming conflicts.",
5
+ description: "Avoid naming conflicts between a property and a model of the same name.",
6
6
  severity: "warning",
7
7
  messages: {
8
- default: paramMessage `Property '${"propertyName"}' having the same name as its enclosing model will cause problems with C# code generation. Consider renaming the property directly or using the @projectedName decorator to rename the property for C#.`,
9
- projectedName: paramMessage `Use of @projectedName on property '${"propertyName"}' results in '${"propertyName"}' having the same name as its enclosing type in C#. Please use a different @projectedName value.`,
8
+ default: paramMessage `Property '${"propertyName"}' having the same name as its enclosing model will cause problems with C# code generation. Consider renaming the property directly or using the @clientName("newName", "csharp") decorator to rename the property for C#.`,
10
9
  },
11
10
  create(context) {
12
11
  return {
13
12
  modelProperty: (property) => {
14
- var _a, _b, _c;
13
+ var _a;
15
14
  if (isExcludedCoreType(context.program, property))
16
15
  return;
17
- const projectedNames = getProjectedNames(context.program, property);
18
16
  const modelName = (_a = property.model) === null || _a === void 0 ? void 0 : _a.name.toLocaleLowerCase();
19
17
  const propertyName = property.name.toLocaleLowerCase();
20
- const csharpProjection = (_b = projectedNames === null || projectedNames === void 0 ? void 0 : projectedNames.get("csharp")) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase();
21
- const clientProjection = (_c = projectedNames === null || projectedNames === void 0 ? void 0 : projectedNames.get("client")) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase();
22
- if (csharpProjection === modelName || // csharp projection conflicts with model name
23
- (clientProjection === modelName && !csharpProjection) // client projection conflicts with model name and there is no csharp projection
24
- ) {
25
- context.reportDiagnostic({
26
- messageId: "projectedName",
27
- format: { propertyName: property.name },
28
- target: property,
29
- });
30
- }
31
- else if (propertyName === modelName && !(csharpProjection || clientProjection)) {
32
- // warning if the property name conflicts with the model name and there is no csharp or client projected name
18
+ if (propertyName === modelName) {
33
19
  context.reportDiagnostic({
34
20
  format: { propertyName: property.name },
35
21
  target: property,
@@ -1 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AAiB,EAAE,CAAC;gBACvD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;oBAC/B,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE;wBACvC,MAAM,EAAE,QAAQ;qBACjB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -5,7 +5,7 @@ export const requireDocumentation = createRule({
5
5
  description: "Require documentation over enums, models, and operations.",
6
6
  severity: "warning",
7
7
  messages: {
8
- default: paramMessage `The ${"kind"} named '${"name"}' should have a documentation or description, please use decorator @doc to add it.`,
8
+ default: paramMessage `The ${"kind"} named '${"name"}' should have a documentation or description, use doc comment /** */ to provide it.`,
9
9
  },
10
10
  create(context) {
11
11
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"require-docs.js","sourceRoot":"","sources":["../../../src/rules/require-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,2DAA2D;IACxE,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,OAAO,MAAM,WAAW,MAAM,oFAAoF;KACxI;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,CAAC,OAAa,EAAE,EAAE;gBACtB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;oB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;4BACb,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;yBAC/C,CAAC,CAAC;oBACL,CAAC;oBACD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;wBAC7C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;4BACnC,OAAO,CAAC,gBAAgB,CAAC;gCACvB,MAAM,EAAE,IAAI;gCACZ,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;6BAC7C,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-azure-core",
3
- "version": "0.41.0-dev.3",
3
+ "version": "0.41.0-dev.4",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Core library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",