Skip to content

Commit

Permalink
Merge pull request #4 from hleduff/feat/typescript
Browse files Browse the repository at this point in the history
Move to TypeScript
  • Loading branch information
hleduff authored Jan 8, 2023
2 parents 4812cae + b40cb49 commit d801187
Show file tree
Hide file tree
Showing 35 changed files with 3,272 additions and 3,676 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules/*
.DS_Store
dist
.eslintrc.js
vite.config.js
vite.config.ts
99 changes: 83 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,38 @@ module.exports = {
env: {
browser: true,
node: true,
amd: true,
es6: true,
},
extends: ['plugin:react/recommended', 'airbnb-base', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaVersion: 'latest',
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'airbnb/hooks',
'airbnb-typescript',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/recommended',
],
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
typescript: {
project: './tsconfig.json',
},
},
},
plugins: ['react', 'simple-import-sort', 'import'],
plugins: ['react', '@typescript-eslint'],
rules: {
'react/react-in-jsx-scope': 'off',
'react/display-name': 'off',
'jsx-a11y/accessible-emoji': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'no-console': 'warn',
'no-plusplus': 'off',
'no-else-return': 'off',
Expand Down Expand Up @@ -63,7 +66,7 @@ module.exports = {
],
'import/prefer-default-export': 'off',
'class-methods-use-this': 'off',
'nonblock-statement-body-position': ['error', 'beside'],
'nonblock-statement-body-position': ['error', 'below'],
camelcase: [
'error',
{
Expand All @@ -73,5 +76,69 @@ module.exports = {
],
'no-prototype-builtins': 'off',
'no-await-in-loop': 'off',
'react/display-name': 'off',
'no-underscore-dangle': [
'error',
{
allow: [],
allowAfterThis: true,
allowAfterSuper: false,
enforceInMethodNames: true,
},
],
'no-console': 'off',
'no-nested-ternary': 'off',
'nonblock-statement-body-position': ['error', 'beside'],
'newline-after-var': 'error',
'jsx-quotes': ['error', 'prefer-double'],
'max-len': 'off',
'import/no-unresolved': 'warn',
'import/no-cycle': 'off',
'react/display-name': 'off',
'react/react-in-jsx-scope': 'off',
'react/jsx-wrap-multilines': [
'error',
{
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line',
},
],
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/indent': [
'error',
4,
{
SwitchCase: 1,
/**
* Need to ignore rule on class files with decorator to avoid over-indented attribute
* https://github.com/typescript-eslint/typescript-eslint/issues/1824
*/
ignoredNodes: [
'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key',
],
},
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/lines-between-class-members': [
'error',
'always',
{
exceptAfterSingleLine: true,
},
],
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/space-before-function-paren': ['error', 'always'],
'@typescript-eslint/type-annotation-spacing': 'error',
},
};
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
pnpm run lint
5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

8 changes: 0 additions & 8 deletions .prettierrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
"version": "1.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "tsc && vite build",
"preview": "vite preview",
"lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --quiet --fix --ignore-path ./.gitignore",
"lint:format": "prettier --loglevel warn --write \"./**/*.{js,jsx,css,md,json}\" ",
"lint": "pnpm run lint:format && pnpm run lint:fix",
"lint": "eslint",
"lint:fix": "pnpm run lint --fix",
"type-check": "tsc",
"prepare": "husky install"
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.1",
"axios": "^1.2.2",
"classnames": "^2.3.2",
"normalize.css": "^8.0.1",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
Expand All @@ -26,21 +25,21 @@
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"@vitejs/plugin-react-swc": "^3.0.0",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint": "^8.30.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"husky": "^8.0.2",
"lint-staged": "^13.1.0",
"prettier": "2.8.1",
"typescript": "^4.9.4",
"vite": "^4.0.0"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
Loading

0 comments on commit d801187

Please sign in to comment.