Skip to content

Commit

Permalink
Update dependencies and fux ESLint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
m4tt72 committed Dec 25, 2023
1 parent a1b5a35 commit d59fa1a
Show file tree
Hide file tree
Showing 14 changed files with 747 additions and 1,081 deletions.
19 changes: 12 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module.exports = {
plugins: ['prettier'],
extends: ['next/core-web-vitals'],
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:@next/next/recommended',
],
ignorePatterns: ['dist', '.eslintrc.js'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'no-console': 'error',
'prettier/prettier': 'warn',
'react-hooks/exhaustive-deps': 'off',
'react/display-name': 'off',
'import/no-anonymous-default-export': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
};
41 changes: 19 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,37 @@
"start": "next start",
"build": "next build",
"dev": "next dev",
"next": "next",
"preexport": "next build",
"export": "next export",
"lint": "eslint .",
"lint": "next lint",
"prepare": "husky install"
},
"dependencies": {
"@m4tt72/matomo-tracker-react": "^0.6.2",
"axios": "^1.6.0",
"axios": "^1.6.2",
"cowsay-browser": "^1.1.8",
"date-fns": "^2.30.0",
"next": "^14.0.1",
"date-fns": "^3.0.6",
"next": "^14.0.4",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "^4.11.0"
"react-icons": "^4.12.0"
},
"devDependencies": {
"@types/node": "^20.8.10",
"@types/react": "^18.2.33",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@next/eslint-plugin-next": "^14.0.4",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"autoprefixer": "^10.4.16",
"eslint": "8.52.0",
"eslint-config-next": "^14.0.1",
"eslint-plugin-next": "^0.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"eslint": "^8",
"eslint-config-next": "^14.0.4",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"husky": "^8.0.3",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
"tailwindcss": "^3.3.5",
"typescript": "^5.2.2"
"postcss": "^8.4.32",
"prettier": "^3.1.1",
"tailwindcss": "^3.4.0",
"typescript": "^5"
},
"engines": {
"node": ">=18.17.0"
"node": ">=20.10.0"
}
}
9 changes: 1 addition & 8 deletions src/components/input/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMatomo } from '@m4tt72/matomo-tracker-react';
import React, { useEffect, useState } from 'react';
import { commandExists } from '../../utils/commandExists';
import { useShell } from '../../utils/shellProvider';
Expand All @@ -7,7 +6,6 @@ import { useTheme } from '../../utils/themeProvider';
import { Ps1 } from '../ps1';

export const Input = ({ inputRef, containerRef }) => {
const { trackEvent } = useMatomo();
const { theme } = useTheme();
const [value, setValue] = useState('');
const {
Expand All @@ -21,7 +19,7 @@ export const Input = ({ inputRef, containerRef }) => {

useEffect(() => {
containerRef.current.scrollTo(0, containerRef.current.scrollHeight);
}, [history]);
}, [history, containerRef]);

const onSubmit = async (event: React.KeyboardEvent<HTMLInputElement>) => {
const commands: string[] = history
Expand Down Expand Up @@ -58,11 +56,6 @@ export const Input = ({ inputRef, containerRef }) => {
setCommand(value);

setValue('');

trackEvent({
category: 'Command Executed',
action: value || 'no command',
});
}

if (event.key === 'ArrowUp') {
Expand Down
4 changes: 1 addition & 3 deletions src/components/ps1/Ps1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export const Ps1 = () => {
const { theme } = useTheme();

useEffect(() => {
if (typeof window !== undefined) {
setHostname(window.location.hostname);
}
setHostname(window.location.hostname);
}, []);

return (
Expand Down
23 changes: 1 addition & 22 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createInstance, MatomoProvider } from '@m4tt72/matomo-tracker-react';
import Head from 'next/head';
import React, { useEffect } from 'react';
import { Layout } from '../components/layout';
Expand Down Expand Up @@ -49,25 +48,5 @@ const App = ({ Component, pageProps }) => {
};

export default (props) => {
const ENABLE_TRACKING = Boolean(+process.env.NEXT_PUBLIC_ENABLE_TRACKING);

if (!ENABLE_TRACKING) {
return <App {...props} />;
}

const instance = createInstance({
urlBase: process.env.NEXT_PUBLIC_TRACKING_URL,
trackerUrl: `${process.env.NEXT_PUBLIC_TRACKING_URL}/js/`,
srcUrl: `${process.env.NEXT_PUBLIC_TRACKING_URL}/js/`,
siteId: +process.env.NEXT_PUBLIC_TRACKING_SITE_ID,
configurations: {
setRequestMethod: 'GET',
},
});

return (
<MatomoProvider value={instance}>
<App {...props} />
</MatomoProvider>
);
return <App {...props} />;
};
8 changes: 1 addition & 7 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMatomo } from '@m4tt72/matomo-tracker-react';
import Head from 'next/head';
import React from 'react';
import { History } from '../components/history';
Expand All @@ -12,21 +11,16 @@ interface IndexPageProps {
}

const IndexPage: React.FC<IndexPageProps> = ({ inputRef }) => {
const { trackPageView } = useMatomo();
const { history } = useShell();
const { theme } = useTheme();

const containerRef = React.useRef(null);

React.useEffect(() => {
trackPageView({});
}, []);

React.useEffect(() => {
if (inputRef.current) {
inputRef.current.focus();
}
}, [history]);
}, [history, inputRef]);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/bin/about.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getBio } from '../../api';

export const about = async (args: string[]): Promise<string> => {
export const about = async (_args: string[]): Promise<string> => {
const bio = await getBio();

return bio;
Expand Down
60 changes: 30 additions & 30 deletions src/utils/bin/neofetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ const macos = `
OMMM0,
.;loddo:' loolloddol;.
cKMMMMMMMMMMNWMMMMMMMMMM0:
.KMMMMMMMMMMMMMMMMMMMMMMMWd.
XMMMMMMMMMMMMMMMMMMMMMMMX.
;MMMMMMMMMMMMMMMMMMMMMMMM:
:MMMMMMMMMMMMMMMMMMMMMMMM:
.MMMMMMMMMMMMMMMMMMMMMMMMX.
kMMMMMMMMMMMMMMMMMMMMMMMMWd.
.XMMMMMMMMMMMMMMMMMMMMMMMMMMk
.XMMMMMMMMMMMMMMMMMMMMMMMMK.
kMMMMMMMMMMMMMMMMMMMMMMd
;KMMMMMMMWXXWMMMMMMMk.
.cooc,. .,coo:.
.KMMMMMMMMMMMMMMMMMMMMMMMWd.
XMMMMMMMMMMMMMMMMMMMMMMMX.
;MMMMMMMMMMMMMMMMMMMMMMMM:
:MMMMMMMMMMMMMMMMMMMMMMMM:
.MMMMMMMMMMMMMMMMMMMMMMMMX.
kMMMMMMMMMMMMMMMMMMMMMMMMWd.
.XMMMMMMMMMMMMMMMMMMMMMMMMMMk
.XMMMMMMMMMMMMMMMMMMMMMMMMK.
kMMMMMMMMMMMMMMMMMMMMMMd
;KMMMMMMMWXXWMMMMMMMk.
.cooc,. .,coo:.
`;

const windows = `
Expand All @@ -32,34 +32,34 @@ llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
\`'ccllllllllll lllllllllllllllllll
\`' \*:: :ccllllllllllllllll
\`' *:: :ccllllllllllllllll
\`\`\`\`''*::cll
`;

const linux = `
.-/+oossssoo+/-.
\`:+ssssssssssssssssss+:\`
-+ssssssssssssssssssyyssss+-
.ossssssssssssssssssdMMMNysssso.
/ssssssssssshdmmNNmmyNMMMMhssssss/
+ssssssssshmydMMMMMMMNddddyssssssss+
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
ossyNMMMNyMMhsssssssssssssshmmmhssssssso
ossyNMMMNyMMhsssssssssssssshmmmhssssssso
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
+sssssssssdmydMMMMMMMMddddyssssssss+
/ssssssssssshdmNNNNmyNMMMMhssssss/
.-/+oossssoo+/-.
\`:+ssssssssssssssssss+:\`
-+ssssssssssssssssssyyssss+-
.ossssssssssssssssssdMMMNysssso.
/ssssssssssshdmmNNmmyNMMMMhssssss/
+ssssssssshmydMMMMMMMNddddyssssssss+
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
ossyNMMMNyMMhsssssssssssssshmmmhssssssso
ossyNMMMNyMMhsssssssssssssshmmmhssssssso
+sssshhhyNMMNyssssssssssssyNMMMysssssss+
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
+sssssssssdmydMMMMMMMMddddyssssssss+
/ssssssssssshdmNNNNmyNMMMMhssssss/
.ossssssssssssssssssdMMMNysssso.
-+sssssssssssssssssyyyssss+-
\`:+ssssssssssssssssss+:\`
Expand Down Expand Up @@ -147,7 +147,7 @@ const getInfo = () => {
return message;
};

export const neofetch = async (args?: string[]): Promise<string> => {
export const neofetch = async (_args?: string[]): Promise<string> => {
const art = getArt();
const info = getInfo();

Expand Down
2 changes: 1 addition & 1 deletion src/utils/bin/projects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getProjects } from '../../api';

export const projects = async (args: string[]): Promise<string> => {
export const projects = async (_args: string[]): Promise<string> => {
const projects = await getProjects();

return projects
Expand Down
6 changes: 3 additions & 3 deletions src/utils/bin/social.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import config from '../../../config.json';

export const instagram = async (args: string[]): Promise<string> => {
export const instagram = async (_args: string[]): Promise<string> => {
window.open(`https://www.instagram.com/${config.social.instagram}/`);

return 'Opening instagram...';
};

export const github = async (args: string[]): Promise<string> => {
export const github = async (_args: string[]): Promise<string> => {
window.open(`https://github.com/${config.social.github}/`);

return 'Opening github...';
};

export const linkedin = async (args: string[]): Promise<string> => {
export const linkedin = async (_args: string[]): Promise<string> => {
window.open(`https://www.linkedin.com/in/${config.social.linkedin}/`);

return 'Opening linkedin...';
Expand Down
30 changes: 20 additions & 10 deletions src/utils/bin/theme.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
import Themes from '../../../themes.json';

export const theme = async (
args: string[],
callback?: (value: string) => string,
): Promise<string> => {
if (args.length === 0) {
return `Usage: theme [arg]
const help = `Usage: theme [arg]
Args:
- ls: list all themes
- set: set a theme
- random: set a random theme
Example:
Example:
theme ls # to list all themes
theme set Gruvbox # to set a theme`;

export const theme = async (
args: string[],
callback?: (value: string) => string,
): Promise<string> => {
if (args.length === 0) {
return help;
}

switch (args[0]) {
case 'ls':
case 'ls': {
let result = Themes.map((theme) => theme.name.toLowerCase()).join(', ');
result += '\n\n';
result += `You can preview all these themes <a href="https://github.com/m4tt72/terminal/tree/master/docs/themes">in the docs</a>`;

return result;
case 'set':
}

case 'set': {
const selectedTheme = args[1];

return callback(selectedTheme);
case 'random':
}

case 'random': {
const randomTheme = Themes[Math.floor(Math.random() * Themes.length)];

return callback(randomTheme.name.toLowerCase());
}

default:
return help;
}
};
Loading

0 comments on commit d59fa1a

Please sign in to comment.