Skip to content

Commit

Permalink
Fix eslint configuration and adjust rules for same
Browse files Browse the repository at this point in the history
  • Loading branch information
siddg97 committed Feb 11, 2024
1 parent 25f4502 commit 2bc1513
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 154 deletions.
61 changes: 36 additions & 25 deletions react/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
module.exports = {
"env": {
"browser": true,
"es2021": true,
"node": true
env: {
browser: true,
es2021: true,
node: true,
},
"extends": [
"standard-with-typescript",
"plugin:react/recommended"
extends: [
'standard-with-typescript',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'prettier',
],
"overrides": [
settings: {
react: {
version: 'detect',
},
},
overrides: [
{
"env": {
"node": true
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
},
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
},
"plugins": [
"react"
],
"rules": {}
}
plugins: ['react'],
rules: {
'spaced-comment': 'off',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
},
};
3 changes: 2 additions & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite",
"build": "tsc && vite build",
"prebuild": "yarn lint",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives",
"test": "echo 'No tests for now'",
"test:ci": "echo 'No tests for now'",
"preview": "vite preview"
Expand All @@ -32,6 +32,7 @@
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.17",
"eslint": "^8.0.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
Expand Down
2 changes: 1 addition & 1 deletion react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function App() {
}
>
{routes.map(r => (
<Route index={r.path === '/'} path={r.path} element={r.component} />
<Route key={`route-${r.path}`} index={r.path === '/'} path={r.path} element={r.component} />
))}
{/*<Route path='*' element={<NoMatch />} />*/}
</Route>
Expand Down
4 changes: 2 additions & 2 deletions react/src/components/containers/PageContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';
import type { ReactNode } from 'react';

type Props = {
interface Props {
children: ReactNode;
};

Expand Down
8 changes: 4 additions & 4 deletions react/src/components/navigation/NavigationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { NavbarItem, NavbarMenuItem } from '@nextui-org/react';
import { ReactNode } from 'react';
import { NavLink, Path, useMatch, useResolvedPath } from 'react-router-dom';
import type { ReactNode } from 'react';
import { NavLink, useMatch, useResolvedPath } from 'react-router-dom';

type Props = {
interface Props {
path: string;
text: ReactNode;
mobile?: boolean;
};

function NavigationLink({ path, text, mobile = false }: Props) {

Check warning on line 11 in react/src/components/navigation/NavigationLink.tsx

View workflow job for this annotation

GitHub Actions / Test-and-Build (20.x)

Missing return type on function
const resolvedPath: Path = useResolvedPath(path);
const resolvedPath = useResolvedPath(path);
const matchedPath = useMatch({
path: resolvedPath.pathname,
end: true,
Expand Down
5 changes: 1 addition & 4 deletions react/src/pages/Projects.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

function Projects() {

Check warning on line 1 in react/src/pages/Projects.tsx

View workflow job for this annotation

GitHub Actions / Test-and-Build (20.x)

Missing return type on function
return (
<div>Projects</div>
);
return <div>Projects</div>;
}

export { Projects };
8 changes: 4 additions & 4 deletions react/src/utils/cn.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ClassValue } from "clsx";
import type { ClassValue } from 'clsx';

import clsx from "clsx";
import { twMerge } from "tailwind-merge";
import clsx from 'clsx';
import { twMerge } from 'tailwind-merge';

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
return twMerge(clsx(inputs));
}
Loading

0 comments on commit 2bc1513

Please sign in to comment.