Skip to content

Commit

Permalink
Code review: Add type on the whole object
Browse files Browse the repository at this point in the history
  • Loading branch information
tondi committed Mar 18, 2024
1 parent f53650f commit c0dc674
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
"error",
{ config: noCyclicModulesImportsConfig },
],
"plentific/enforce-eslint-mandatory-prop": [
"plentific/enforce-mandatory-prop": [
"error",
{ config: enforceEslintMandatoryPropConfig },
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentWithEslintMandatoryProp } from "examples/app/components/ComponentWithEslintMandatoryProp";

export const Usage = () => {
export const Example = () => {
return (
<>
<ComponentWithEslintMandatoryProp
Expand All @@ -9,10 +9,10 @@ export const Usage = () => {
otherEslintMandatoryProp
/>
{/* This component is missing both `eslintMandatoryProp` and `otherEslintMandatoryProp` and should show two eslint errors */}
{/* eslint-disable-next-line plentific/enforce-eslint-mandatory-prop */}
{/* eslint-disable-next-line plentific/enforce-mandatory-prop */}
<ComponentWithEslintMandatoryProp someMandatoryProp />
{/* This component is missing `otherEslintMandatoryProp` and should show an eslint error */}
{/* eslint-disable-next-line plentific/enforce-eslint-mandatory-prop */}
{/* eslint-disable-next-line plentific/enforce-mandatory-prop */}
<ComponentWithEslintMandatoryProp someMandatoryProp eslintMandatoryProp />
</>
);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
"no-concurrent-async": require("./rules/no-concurrent-async"),
"no-deprecated-components": require("./rules/no-deprecated-components"),
"no-cyclic-modules-imports": require("./rules/no-cyclic-modules-imports"),
"enforce-eslint-mandatory-prop": require("./rules/enforce-eslint-mandatory-prop"),
"enforce-mandatory-prop": require("./rules/enforce-mandatory-prop"),
"no-trailing-slash": require("./rules/no-trailing-slash"),
"no-window-location-replace": require("./rules/no-window-location-replace"),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
// @ts-check
const hasProp = require("jsx-ast-utils/hasProp");

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
/** @type {import('eslint').Rule.RuleMetaData} */
meta: {
type: "problem",
docs: {
description: "Enforce passing a mandatory prop to a component",
description:
"Enforce passing a mandatory prop to a component based on a configurable list of components and their mandatory props",
},
schema: [
{
type: "object",
additionalProperties: {
type: "object",
additionalProperties: {
type: "object",
additionalProperties: {
type: "boolean",
},
},
},
},
],
},
/** @type {import('eslint').Rule.RuleModule['create']} */
create: function (context) {
const config = context.options[0].config;

Expand Down

0 comments on commit c0dc674

Please sign in to comment.