Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TL-DYS-27] [TL-DYS-28] Added pre-commit and added/fix linting and prettier format #7

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged --concurrent false --relative
1,324 changes: 1,324 additions & 0 deletions README.md

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended", "plugin:prettier/recommended"],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
"prettier/prettier": [
"error",
{
endOfLine: "auto",
},
],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
}
};
3 changes: 3 additions & 0 deletions client/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"src/**/*.{ts,tsx,js,jsx,json,css,scss,md}": ["eslint --quiet --fix", "prettier --write"]
}
13 changes: 13 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --quiet --fix",
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css}\"",
"preview": "vite preview"
},
"dependencies": {
Expand Down Expand Up @@ -36,10 +38,21 @@
"@typescript-eslint/parser": "^6.7.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"prettier": "^3.0.3",
"typescript": "^5.0.2",
"vite": "^4.4.5"
},
"prettier": {
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"printWidth": 200,
"tabWidth": 2,
"endOfLine": "auto"
},
"homepage": "https://www.diyspire.online"
}
10 changes: 8 additions & 2 deletions client/src/components/CustomMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ const CustomMarkdown: React.FC<CustomMarkdownrProps> = ({ content }) => {
h6: { component: Heading, props: { as: "h6", size: "xs", mb: 3 } },
p: { component: Text, props: { mb: 5 } },
ul: { component: List, props: { styleType: "disc", ml: 4, mb: 4 } },
ol: { component: List, props: { styleType: "decimal", ml: 4, mb: 4 } },
ol: {
component: List,
props: { styleType: "decimal", ml: 4, mb: 4 },
},
li: { component: ListItem, props: { mb: 3 } },
a: { component: Link, props: { mb: 2, textDecorationLine: "underline" } },
a: {
component: Link,
props: { mb: 2, textDecorationLine: "underline" },
},
img: { component: Image, props: { mb: 4, loading: "lazy" } },
pre: {
component: MarkdownPre,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/generate/BudgetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const BudgetFilter: React.FC<BudgetFilterProps> = ({ onBudgetChange, ...props })
(value: string | number) => {
onBudgetChange(Number(value));
},
[onBudgetChange]
[onBudgetChange],
);

return (
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/generate/MaterialInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MaterialInput: FC<MaterialInputProps> = ({ materials, setMaterials, onlySp
updatedMaterials[index] = value;
setMaterials(updatedMaterials);
},
[materials, setMaterials]
[materials, setMaterials],
);

const handleDeleteInput = useCallback(
Expand All @@ -25,7 +25,7 @@ const MaterialInput: FC<MaterialInputProps> = ({ materials, setMaterials, onlySp
updatedMaterials.splice(index, 1);
setMaterials(updatedMaterials);
},
[materials, setMaterials]
[materials, setMaterials],
);

const handleAddMore = useCallback(() => {
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/generate/ProjectTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ interface ProjectTabsProps {
type OmittedProject = Omit<Project, "steps">;

const ProjectTabs: React.FC<ProjectTabsProps> = ({ projects }) => {
const tabOrientation = useBreakpointValue({ base: "vertical", md: "horizontal" }) as "vertical" | "horizontal" | undefined;
const tabOrientation = useBreakpointValue({
base: "vertical",
md: "horizontal",
}) as "vertical" | "horizontal" | undefined;
const toast = useToast();

const handleShare = async (project: Project) => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/generate/TimeAvailabilityFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TimeAvailabilityFilter: React.FC<TimeAvailabilityFilterProps> = ({ onTimeC
setTimeValue(value);
onTimeChange(value);
},
[onTimeChange]
[onTimeChange],
);

return (
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/generate/ToolsAvailableInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ToolsAvailableInput: React.FC<ToolsAvailableInputProps> = ({ tools, setToo
newTools[index] = value;
setTools(newTools);
},
[tools, setTools]
[tools, setTools],
);

const handleDeleteTool = useCallback(
Expand All @@ -23,7 +23,7 @@ const ToolsAvailableInput: React.FC<ToolsAvailableInputProps> = ({ tools, setToo
newTools.splice(index, 1);
setTools(newTools);
},
[tools, setTools]
[tools, setTools],
);

return (
Expand Down
1 change: 0 additions & 1 deletion client/src/components/project-details/ProjectImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { RelatedImages } from "../../types";

interface ProjectImageProps {
isLoading: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
relatedImages: RelatedImages | null;
projectTitle: string;
onOpen: () => void;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/project-details/ProjectInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ProjectLocationState } from "../../types";

interface ProjectInfoProps {
isLoading: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
project: ProjectLocationState;
}

Expand All @@ -14,6 +13,7 @@ const ProjectInfo: React.FC<ProjectInfoProps> = ({ isLoading, project }) => {
const description = useColorModeValue("gray.500", "gray.400");
const toolsAndMaterials = useColorModeValue("yellow.500", "yellow.300");
const ellipsisBreakpoint = useBreakpointValue({ base: undefined, lg: 3 });

if (isLoading) {
return (
<>
Expand Down
6 changes: 5 additions & 1 deletion client/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export const footerData: Footer[] = [
links: [
{ label: "Getting Started", path: "/faq", hash: "#getting-started" },
{ label: "Usage Guidelines", path: "/faq", hash: "#usage-guidelines" },
{ label: "Security and Privacy", path: "/faq", hash: "#security-privacy" },
{
label: "Security and Privacy",
path: "/faq",
hash: "#security-privacy",
},
{ label: "Feedback and Suggestions", path: "/faq", hash: "#feedback" },
],
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
<App />
</ChakraProvider>
</Router>
</React.StrictMode>
</React.StrictMode>,
);
2 changes: 1 addition & 1 deletion client/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const Home = () => {
<PurposeFilter onPurposeChange={setPurpose} mt={4} />
</Box>
),
[tools]
[tools],
);

return (
Expand Down
Loading