Skip to content

Commit

Permalink
style: fix linting violations (#8189)
Browse files Browse the repository at this point in the history
**Related Issue:** N/A

## Summary

Extracts linting fixes from
https://github.com/Esri/calcite-design-system/pull/6958/files.
  • Loading branch information
jcfranco authored Nov 16, 2023
1 parent 91968a9 commit 6d0a2d6
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 67 deletions.
2 changes: 1 addition & 1 deletion packages/calcite-components-react/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>

For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA

email: contracts@esri.com
email: <contracts@esri.com>
4 changes: 2 additions & 2 deletions packages/calcite-components-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ All rights reserved under the copyright laws of the United States and applicable

This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.

See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>

For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA

email: contracts@esri.com
email: <contracts@esri.com>
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export const FloatingArrow: FunctionalComponent<FloatingArrowProps> = ({
class={CSS.arrow}
height={width}
key={key}
ref={ref}
viewBox={`0 0 ${width} ${width + (!isVertical ? strokeWidth : 0)}`}
width={width + (isVertical ? strokeWidth : 0)}
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
ref={ref}
>
{strokeWidth > 0 && (
<path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ export class ValueListItem
data-js-handle
onBlur={this.handleBlur}
onKeyDown={this.handleKeyDown}
ref={(el) => (this.handleEl = el as HTMLSpanElement)}
role="button"
tabindex="0"
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
ref={(el) => (this.handleEl = el as HTMLSpanElement)}
>
<calcite-icon flipRtl={iconFlipRtl} icon={ICONS.drag} scale="s" />
</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-calcite-components/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>

For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA

email: contracts@esri.com
email: <contracts@esri.com>
8 changes: 4 additions & 4 deletions packages/eslint-plugin-calcite-components/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const config = {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
statements: 80,
},
},
transform: {
"^.+\\.ts$": "ts-jest"
}
"^.+\\.ts$": "ts-jest",
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import recommended from "./recommended";

export default {
base,
recommended
recommended,
};
24 changes: 12 additions & 12 deletions packages/eslint-plugin-calcite-components/src/rules/ban-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const rule: Rule.RuleModule = {
meta: {
docs: {
description: "This rule catches helps ban or warn against listened event types",
category: "Consistency"
category: "Consistency",
},
schema: {
type: "array",
Expand All @@ -19,17 +19,17 @@ const rule: Rule.RuleModule = {
event: { type: "string" },
message: {
type: "string",
minLength: 1
}
minLength: 1,
},
},
additionalProperties: false,
required: ["event"]
}
]
required: ["event"],
},
],
},
uniqueItems: true
uniqueItems: true,
},
type: "problem"
type: "problem",
},

create: function (context): Rule.RuleListener {
Expand All @@ -54,7 +54,7 @@ const rule: Rule.RuleModule = {
if (bannedEventToMessageLookup.has(eventName)) {
context.report({
node,
message: buildMessage(eventName)
message: buildMessage(eventName),
});
}
}
Expand All @@ -68,13 +68,13 @@ const rule: Rule.RuleModule = {
if (bannedEventToMessageLookup.has(eventName)) {
context.report({
node,
message: buildMessage(eventName)
message: buildMessage(eventName),
});
}
}
}
},
};
}
},
};

export default rule;
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ const rule: Rule.RuleModule = {
docs: {
description: "This rule catches usage of banned props on <Host>.",
category: "Possible Errors",
recommended: true
recommended: true,
},
schema: [
{
type: "array",
items: {
type: "string"
type: "string",
},
minLength: 1,
additionalProperties: false
}
additionalProperties: false,
},
],
type: "problem"
type: "problem",
},

create(context): Rule.RuleListener {
Expand All @@ -42,13 +42,15 @@ const rule: Rule.RuleModule = {
if (unauthorizedAttributes.length > 0) {
context.report({
node: node,
message: `Avoid setting unnecessary attributes/properties on <Host>: ${unauthorizedAttributes.join(", ")}`
message: `Avoid setting unnecessary attributes/properties on <Host>: ${unauthorizedAttributes.join(
", "
)}`,
});
}
}
}
},
};
}
},
};

export default rule;
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const rule: Rule.RuleModule = {
description:
"This rule helps enforce the payload type to EventEmitters to avoid misleading `any` type on the CustomEvent detail object.",
category: "Best practices",
recommended: true
recommended: true,
},
schema: [],
type: "problem"
type: "problem",
},

create(context): Rule.RuleListener {
Expand All @@ -28,7 +28,7 @@ const rule: Rule.RuleModule = {
if (!typedAsEventEmitter) {
context.report({
node,
message: "Emitter not typed as `EventEmitter<CustomEventDetailsType>`"
message: "Emitter not typed as `EventEmitter<CustomEventDetailsType>`",
});
return;
}
Expand All @@ -38,13 +38,13 @@ const rule: Rule.RuleModule = {
if (eventEmitterType === undefined) {
context.report({
node,
message: "EventEmitter is not typed and will cause its detail object to be typed as `any`"
message: "EventEmitter is not typed and will cause its detail object to be typed as `any`",
});
}
}
}
},
};
}
},
};

export default rule;
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const rule: Rule.RuleModule = {
description:
"This rule catches Stencil boolean Props that would not be able to be set to false with HTML5-compliant attributes.",
category: "Possible Errors",
recommended: false
recommended: false,
},
schema: [],
type: "problem"
type: "problem",
},

create(context): Rule.RuleListener {
Expand All @@ -26,13 +26,13 @@ const rule: Rule.RuleModule = {
if (initializer === true) {
context.report({
node: node.key,
message: `Boolean properties decorated with @Prop() should not be initialized to true`
message: `Boolean properties decorated with @Prop() should not be initialized to true`,
});
}
}
}
},
};
}
},
};

export default rule;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const projectPath = path.resolve(__dirname, "../../../tsconfig.json");
describe("stencil rules", () => {
const files = {
good: path.resolve(__dirname, "ban-events.good.tsx"),
wrong: path.resolve(__dirname, "ban-events.wrong.tsx")
wrong: path.resolve(__dirname, "ban-events.wrong.tsx"),
};

const options = ["some-unsupported-event", { event: "keypress", message: "use keyup or keydown instead" }];
Expand All @@ -18,17 +18,17 @@ describe("stencil rules", () => {
{
code: fs.readFileSync(files.good, "utf8"),
options,
filename: files.good
}
filename: files.good,
},
],

invalid: [
{
code: fs.readFileSync(files.wrong, "utf8"),
options,
filename: files.wrong,
errors: 3
}
]
errors: 3,
},
],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ const projectPath = path.resolve(__dirname, "../../../tsconfig.json");
describe("stencil rules", () => {
const files = {
good: path.resolve(__dirname, "ban-props-on-host.good.tsx"),
wrong: path.resolve(__dirname, "ban-props-on-host.wrong.tsx")
wrong: path.resolve(__dirname, "ban-props-on-host.wrong.tsx"),
};
ruleTester(projectPath).run("ban-props-on-host", rule, {
valid: [
{
code: fs.readFileSync(files.good, "utf8"),
filename: files.good
}
filename: files.good,
},
],

invalid: [
{
code: fs.readFileSync(files.wrong, "utf8"),
filename: files.wrong,
errors: 1
}
]
errors: 1,
},
],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ const projectPath = path.resolve(__dirname, "../../../tsconfig.json");
describe("stencil rules", () => {
const files = {
good: path.resolve(__dirname, "require-event-emitter-type.good.tsx"),
wrong: path.resolve(__dirname, "require-event-emitter-type.wrong.tsx")
wrong: path.resolve(__dirname, "require-event-emitter-type.wrong.tsx"),
};

ruleTester(projectPath).run("require-event-emitter-type", rule, {
valid: [
{
code: fs.readFileSync(files.good, "utf8"),
filename: files.good
}
filename: files.good,
},
],

invalid: [
{
code: fs.readFileSync(files.wrong, "utf8"),
filename: files.wrong,
errors: 2
}
]
errors: 2,
},
],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ const projectPath = path.resolve(__dirname, "../../../tsconfig.json");
describe("stencil rules", () => {
const files = {
good: path.resolve(__dirname, "strict-boolean-attributes.good.tsx"),
wrong: path.resolve(__dirname, "strict-boolean-attributes.wrong.tsx")
wrong: path.resolve(__dirname, "strict-boolean-attributes.wrong.tsx"),
};
ruleTester(projectPath).run("strict-boolean-attributes", rule, {
valid: [
{
code: fs.readFileSync(files.good, "utf8"),
filename: files.good
}
filename: files.good,
},
],

invalid: [
{
code: fs.readFileSync(files.wrong, "utf8"),
filename: files.wrong,
errors: 1
}
]
errors: 1,
},
],
});
});
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>

For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA

email: contracts@esri.com
email: <contracts@esri.com>

0 comments on commit 6d0a2d6

Please sign in to comment.