Skip to content

Commit

Permalink
Merge pull request #10 from crisanlucid/feature/tools-dev-improvement
Browse files Browse the repository at this point in the history
feat: Tools improvement
  • Loading branch information
crisanlucid authored May 7, 2023
2 parents 0b57dae + 46ef7ae commit 7925085
Show file tree
Hide file tree
Showing 14 changed files with 3,366 additions and 95 deletions.
88 changes: 88 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* eslint-env node */
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
root: true,
extends: [
"plugin:vitest-globals/recommended",
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
],
settings: {
react: {
version: "detect",
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
},
env: {
browser: true,
es2022: true,
es6: true,
"vitest-globals/env": true,
"cypress/globals": true,
},
overrides: [
{
files: ["cypress/e2e/**.{cy,spec}.{js,ts,jsx,tsx}"],
extends: ["plugin:cypress/recommended"],
},
{
files: ["*.tsx, *.jsx"],
rules: {
"@typescript-eslint/ban-types": [
"error",
{
extendDefaults: true,
types: {
"{}": false,
},
},
],
"no-unused-expressions": "off",
},
},
{
files: ["*.ts", "*.tsx"],
rules: {
"no-undef": "off",
"@typescript-eslint/no-misused-promises": "off",
},
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: "latest",
sourceType: "module",
project: "tsconfig.json",
},
plugins: ["react", "import", "jsx-a11y", "@typescript-eslint", "cypress"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-unused-vars": "off",
"no-undef": process.env.NODE_ENV === "production" ? "warn" : "error",
"no-unreachable": process.env.NODE_ENV === "production" ? "warn" : "error",
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-unused-vars":
process.env.NODE_ENV === "production" ? "warn" : "error",
"react/prop-types": 0,
"react/react-in-jsx-scope": 0,
"@typescript-eslint/no-empty-function": 0,
},
};
38 changes: 36 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"preview": "vite preview",
"stylelint": "npx stylelint \"./**/*.{css}\" --config \"./stylelint.config.js\"",
"stylelint:fix": "npm run stylelint -- --fix",
"prettier:fix": "prettier --config ./prettier.config.js --write ./src/**/*.{css,ts,tsx} ",
"prettier:check": "prettier --config ./prettier.config.js --check ./src/**/*.{css,ts,tsx}",
"lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --quiet --ignore-path .gitignore",
"lint:fix": "npm run lint -- --fix",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"html2canvas": "^1.4.1",
Expand All @@ -14,11 +21,38 @@
"react-dom": "^18.0.0"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.2.0",
"@tailwindcss/forms": "^0.5.3",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@vitejs/plugin-react": "^1.3.0",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-cypress": "^2.13.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-vitest-globals": "^1.3.1",
"postcss": "^8.4.23",
"postcss-extend": "^1.0.5",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-import": "^15.1.0",
"postcss-mixins": "^9.0.4",
"postcss-nested": "^6.0.1",
"postcss-preset-env": "^8.3.2",
"postcss-reporter": "^7.0.5",
"prettier": "^2.8.8",
"stylelint": "^15.6.0",
"stylelint-config-css-modules": "^4.2.0",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-recess-order": "^4.0.0",
"stylelint-config-recommended": "^12.0.0",
"stylelint-config-standard": "^33.0.0",
"tailwindcss": "^3.0.24",
"typescript": "^4.6.3",
"vite": "^2.9.9"
Expand Down
17 changes: 17 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
module.exports = {
plugins: {
tailwindcss: {},
"postcss-flexbugs-fixes": {},
stylelint: {
configFile: "stylelint.config.js",
},
"postcss-import": {},
"postcss-extend": {},
"postcss-mixins": {},
"postcss-nested": {},
"postcss-preset-env": {
autoprefixer: { flexbox: "no-2009" },
stage: 3,
features: {
"custom-properties": false,
"nesting-rules": false,
},
},
autoprefixer: {},
"postcss-reporter": {},
},
};
13 changes: 13 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env node */
module.exports = {
endOfLine: 'lf',
jsxSingleQuote: true,
printWidth: 100,
proseWrap: 'never',
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
};
13 changes: 13 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env node */
module.exports = {
endOfLine: 'lf',
jsxSingleQuote: true,
printWidth: 100,
proseWrap: 'never',
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
};
8 changes: 4 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useState } from "react";
import "./App.css";
import { BionicReaderPage } from "./pages/BionicReaderPage";
import { useState } from 'react';
import './App.css';
import { BionicReaderPage } from './pages/BionicReaderPage';

function App() {
const [count, setCount] = useState(0);

return (
<div className="App">
<div className='App'>
<BionicReaderPage />
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTextProcessing.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from "react";
import { FC, useState } from "react";

import { timeout } from "../util/helpers";

Expand Down
8 changes: 3 additions & 5 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

.bio-letter {
Expand Down
21 changes: 13 additions & 8 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.css'
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import "./index.css";

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
const container = document.getElementById("root");
if (!container) throw new Error("no container to render to");

const root = createRoot(container);

root.render(
<StrictMode>
<App />
</React.StrictMode>
)
</StrictMode>
);
18 changes: 10 additions & 8 deletions src/pages/BionicReaderPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState, useRef } from "react";
import { FC, useState, useRef } from "react";

import { useTextProcessing } from "../hooks/useTextProcessing";

Expand All @@ -11,13 +11,15 @@ export const BionicReaderPage: FC = () => {
useTextProcessing();
const inputRef = useRef(null);
const printDocument = () => {
html2canvas(inputRef.current as unknown as HTMLElement).then((canvas) => {
const imgData = canvas.toDataURL("image/png");
const pdf = new jsPDF();
const width = pdf.internal.pageSize.getWidth();
pdf.addImage(imgData, "JPEG", 5, 10, width - 10, 0);
pdf.save(FILE_PDF_NAME);
});
html2canvas(inputRef.current as unknown as HTMLElement)
.then((canvas) => {
const imgData = canvas.toDataURL("image/png");
const pdf = new jsPDF();
const width = pdf.internal.pageSize.getWidth();
pdf.addImage(imgData, "JPEG", 5, 10, width - 10, 0);
pdf.save(FILE_PDF_NAME);
})
.catch((e) => console.error(e));
};

return (
Expand Down
39 changes: 39 additions & 0 deletions stylelint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
extends: [
"stylelint-config-standard",
"stylelint-config-recess-order",
"stylelint-config-css-modules",
"stylelint-config-prettier",
],
ignoreFiles: [
"./node_modules/**/*.css",
"./dist/**/*.css",
"./coverage/**/*.css",
],
rules: {
"at-rule-no-unknown": [
true,
{
ignoreAtRules: [
"tailwind",
"apply",
"screen",
"variants",
"responsive",
],
},
],
"no-duplicate-selectors": null,
"no-empty-source": null,
"rule-empty-line-before": null,
"comment-empty-line-before": null,
"selector-pseudo-element-no-unknown": null,
"declaration-block-trailing-semicolon": null,
"no-descending-specificity": null,
"string-no-newline": null,
// Limit the number of universal selectors in a selector,
// to avoid very slow selectors
"selector-max-universal": 1,
"selector-class-pattern": "^[a-z][a-zA-Z0-9]+$",
},
};
34 changes: 20 additions & 14 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const colors = require('tailwindcss/colors');

module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"],
mode: "jit",
content: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
mode: 'jit',
theme: {
fontFamily: {
display: ["Open Sans", "sans-serif"],
body: ["Open Sans", "sans-serif"],
display: ['Open Sans', 'sans-serif'],
body: ['Open Sans', 'sans-serif'],
},
extend: {
colors: {
...colors,
},
screens: {
mf: "990px",
mf: '990px',
},
keyframes: {
"slide-in": {
"0%": {
"-webkit-transform": "translateX(120%)",
transform: "translateX(120%)",
'slide-in': {
'0%': {
'-webkit-transform': 'translateX(120%)',
transform: 'translateX(120%)',
},
"100%": {
"-webkit-transform": "translateX(0%)",
transform: "translateX(0%)",
'100%': {
'-webkit-transform': 'translateX(0%)',
transform: 'translateX(0%)',
},
},
},
animation: {
"slide-in": "slide-in 0.5s ease-out",
'slide-in': 'slide-in 0.5s ease-out',
},
},
},
variants: {
extend: {},
},
plugins: [],
plugins: ['@tailwindcss/forms'],
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"include": ["src", ".eslintrc.cjs", "prettier.config.cjs"],
"references": [{ "path": "./tsconfig.node.json" }]
}
Loading

0 comments on commit 7925085

Please sign in to comment.