Skip to content

Commit

Permalink
Merge pull request #151 from TaskRatchet/return-from-monorepo
Browse files Browse the repository at this point in the history
update deps
  • Loading branch information
narthur authored Aug 6, 2024
2 parents b3ec1a6 + 32c24b9 commit e7a33fa
Show file tree
Hide file tree
Showing 31 changed files with 1,321 additions and 2,182 deletions.
2 changes: 1 addition & 1 deletion .depcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ignores: ['@types/node', '@types/react-dom']
ignores: ["@types/node", "@types/react-dom", "eslint-config-prettier", "eslint-plugin-react-hooks"]
3 changes: 2 additions & 1 deletion .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ VITE_FIREBASE_STORAGE_BUCKET='value'
VITE_FIREBASE_MESSAGING_SENDER_ID='value'
VITE_FIREBASE_APP_ID='value'
VITE_API1_URL=https://api.taskratchet.com/api1/
VITE_API2_URL=https://api.taskratchet.com/api2/
VITE_API2_URL=https://api.taskratchet.com/api2/
VITE_WEB3FORMS_ACCESS_KEY='value'
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

79 changes: 0 additions & 79 deletions .eslintrc.js

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ jobs:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
- name: Strip content hashes from stats files
run: |
sed -i -E 's/index\.[0-9a-zA-Z_-]{8,}\./index./g' ./head-stats/stats.json
sed -i -E 's/\.[0-9a-zA-Z_-]{8,}\.chunk\././g' ./head-stats/stats.json
sed -i -E 's/index\.[0-9a-zA-Z_-]{8,}\./index./g' ./base-stats/stats.json
sed -i -E 's/\.[0-9a-zA-Z_-]{8,}\.chunk\././g' ./base-stats/stats.json
- uses: twk3/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ build
dist
node_modules
pnpm-lock.yaml
stats.html
stats.html
.depcheckrc
74 changes: 22 additions & 52 deletions __mocks__/@mui/x-date-pickers.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,30 @@
import { TextField } from '@mui/material';
import dayjs from 'dayjs';
import React from 'react';
import customParseFormat from 'dayjs/plugin/customParseFormat';

function makePicker({
formatValue,
parseValue,
}: {
formatValue: (value: Date) => string;
parseValue: (value: string) => Date;
}) {
dayjs.extend(customParseFormat);

function makePicker(format: string) {
return function MockPicker(p: any) {
const [value, setValue] = React.useState(formatValue(p.value));
return p.renderInput({
label: p.label,
value,
onChange: (e: any) => {
setValue(e.target.value);
p.onChange({
$d: parseValue(e.target.value),
});
},
...p.InputProps,
});
const [value, setValue] = React.useState(p.value.format(format));
return (
<TextField
{...{
label: p.label,
value,
onChange: (e: any) => {
setValue(e.target.value);
p.onChange(dayjs(e.target.value, format));
},
...p.slotProps.textField,
}}
/>
);
};
}

const DatePicker = makePicker({
formatValue: (value: Date) => {
// MM/DD/YYYY
return value.toLocaleDateString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
});
},
parseValue: (value: string) => {
const [month, day, year] = value.split('/').map(Number);
return new Date(year, month - 1, day);
},
});

const TimePicker = makePicker({
formatValue: (value: Date) => {
// hh:mm A
return value.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit',
hour12: true,
});
},
parseValue: (value: string) => {
// hh:mm A
// example: "12:00 AM"
const ampm = value.slice(-2);
const [hour, minute] = value.slice(0, -2).split(':').map(Number);
const hours = ampm === 'AM' ? hour : hour + 12;
return new Date(0, 0, 0, hours, minute);
},
});
const DatePicker = makePicker('MM/DD/YYYY');
const TimePicker = makePicker('hh:mm A');

export { DatePicker, TimePicker };
124 changes: 124 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import react from 'eslint-plugin-react';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import regex from 'eslint-plugin-regex';
import lodash from 'eslint-plugin-lodash';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
import testingLibrary from 'eslint-plugin-testing-library';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['public', 'src/serviceWorker.js', '**/eslint.config.mjs', 'dist'],
},
...fixupConfigRules(
compat.extends(
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
),
),
{
plugins: {
react: fixupPluginRules(react),
'@typescript-eslint': fixupPluginRules(typescriptEslint),
regex,
lodash,
'testing-library': fixupPluginRules({
rules: testingLibrary.rules,
}),
},

languageOptions: {
globals: {
...globals.browser,
},

parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
jsx: true,
},

project: './tsconfig.json',
},
},

settings: {
react: {
version: 'detect',
},
},

rules: {
'lodash/import-scope': 'error',

'regex/required': [
'error',
[
{
regex: 'describe.+from.+vitest',
message: 'Import `describe` explicitly.',

files: {
inspect: '\\.(test|spec)\\.tsx?$',
},
},
{
regex: 'it.+from.+vitest',
message: 'Import `it` explicitly.',

files: {
inspect: '\\.(test|spec)\\.tsx?$',
},
},
{
regex: 'expect.+from.+vitest',
message: 'Import `expect` explicitly.',

files: {
inspect: '\\.(test|spec)\\.tsx?$',
},
},
],
],
},
},
{
files: [
'**/*.spec.ts',
'**/*.spec.tsx',
'**/__mocks__/**/*',
'**/__tests__/**/*',
'**/global-setup.ts',
'src/lib/test/**/*',
],

rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
},
},
];
8 changes: 2 additions & 6 deletions global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import createFetchMock from 'vitest-fetch-mock';
import { vi, beforeEach, expect, afterEach } from 'vitest';
import matchers, {
TestingLibraryMatchers,
} from '@testing-library/jest-dom/matchers';
import * as matchers from '@testing-library/jest-dom/matchers';
import { cleanup } from '@testing-library/react';
import { redirectToCheckout } from './src/lib/stripe';
import { signOut } from 'firebase/auth';
Expand All @@ -12,9 +10,7 @@ afterEach(() => {
cleanup();
});

const m: TestingLibraryMatchers<string, void> = matchers;

expect.extend(m);
expect.extend(matchers);

// eslint-disable-next-line @typescript-eslint/require-await
module.exports = async () => {
Expand Down
Loading

0 comments on commit e7a33fa

Please sign in to comment.