Skip to content

Commit

Permalink
chore: configure development environment
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarhenrq committed Sep 25, 2023
1 parent 527ac3e commit 560e745
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 177 deletions.
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ build
coverage
public
.docz
global
global
.prettierignore
.eslintrc.js
tsconfig.json
.prettierrc
15 changes: 14 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-var-requires': 'off',
'testing-library/no-render-in-setup': 'off',
semi: ['error', 'always'],
indent: ['error', 2],
'linebreak-style': ['error', 'windows'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
eqeqeq: 'error',
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
bracketSpacing: true,
},
],
},
env: {
browser: true,
amd: true,
node: true,
},
}
};
8 changes: 4 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"endOfLine": "lf",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
Expand All @@ -10,9 +9,10 @@
"proseWrap": "always",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
"useTabs": false,
"endOfLine": "auto"
}
12 changes: 6 additions & 6 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {defineConfig} from 'cypress'
import plugins from './cypress/support/plugins'
import tasks from './cypress/support/tasks'
import { defineConfig } from 'cypress';
import plugins from './cypress/support/plugins';
import tasks from './cypress/support/tasks';

export default defineConfig({
// @ts-expect-error - experimentalSingleTabRunMode is not in the type definition
Expand All @@ -13,8 +13,8 @@ export default defineConfig({
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
tasks(on)
return plugins(on, config)
tasks(on);
return plugins(on, config);
},
},
component: {
Expand All @@ -24,4 +24,4 @@ export default defineConfig({
bundler: 'vite',
},
},
})
});
12 changes: 6 additions & 6 deletions cypress.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {MountOptions, MountReturn} from 'cypress/react'
import { MountOptions, MountReturn } from 'cypress/react';

export {}
export {};
declare global {
namespace Cypress {
interface Chainable {
Expand All @@ -10,7 +10,7 @@ declare global {
* cy.getByCy('search-toggle') // where the selector is [data-cy="search-toggle"]
* ```
*/
getByCy(qaSelector: string, args?: any): Chainable<JQuery<HTMLElement>>
getByCy(qaSelector: string, args?: any): Chainable<JQuery<HTMLElement>>;

/** Yields elements with data-cy attribute that partially matches a specified selector.
* ```
Expand All @@ -20,7 +20,7 @@ declare global {
getByCyLike(
qaSelector: string,
args?: any,
): Chainable<JQuery<HTMLElement>>
): Chainable<JQuery<HTMLElement>>;

/** Yields the element that partially matches the css class
* ```
Expand All @@ -30,7 +30,7 @@ declare global {
getByClassLike(
qaSelector: string,
args?: any,
): Chainable<JQuery<HTMLElement>>
): Chainable<JQuery<HTMLElement>>;

/** Mounts a React node
* @param component React Node to mount
Expand All @@ -39,7 +39,7 @@ declare global {
mount(
component: React.ReactNode,
options?: MountOptions,
): Cypress.Chainable<MountReturn>
): Cypress.Chainable<MountReturn>;
}
}
}
2 changes: 1 addition & 1 deletion cypress/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'off',
},
env: {'cypress/globals': true},
}
};
8 changes: 1 addition & 7 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
describe('e2e sanity', () => {
it('passes sanity', () => {
cy.visit('/')
cy.getByCy('count').contains('count is 0').dblclick().contains('count is 2')
cy.task('log', 'e2e sanity passed')
})
})
describe('e2e', () => {});
2 changes: 1 addition & 1 deletion cypress/support/component-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script>
if (window.parent !== window) {
window['__REACT_DEVTOOLS_GLOBAL_HOOK__'] =
window.parent['__REACT_DEVTOOLS_GLOBAL_HOOK__']
window.parent['__REACT_DEVTOOLS_GLOBAL_HOOK__'];
}
</script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
}
};
6 changes: 3 additions & 3 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom/extend-expect'
import '@testing-library/jest-dom/extend-expect';

import {configure} from '@testing-library/react'
import { configure } from '@testing-library/react';

configure({testIdAttribute: 'data-cy'})
configure({ testIdAttribute: 'data-cy' });
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint": "eslint . --cache-location node_modules/.cache/eslint",
"typecheck": "tsc --noEmit",
"validate": "npm-run-all --parallel format lint typecheck build",
"validate:ci": "npm-run-all --parallel format lint typecheck",
"cy:open": "cypress open",
"cy:open-e2e": "server-test 3000 'cypress open --e2e --browser chrome'",
"cy:run-e2e": "server-test 3000 'cypress run --e2e --browser chrome'",
Expand Down
1 change: 0 additions & 1 deletion public/react.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

42 changes: 0 additions & 42 deletions src/App.css

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.cy.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions src/App.test.tsx

This file was deleted.

30 changes: 1 addition & 29 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
import {useState} from 'react'
import './App.css'

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

return (
<div className="App">
<div>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" className="logo" alt="Vite logo" />
</a>
<a href="https://reactjs.org" target="_blank">
<img src="/react.svg" className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button data-cy="count" onClick={() => setCount(count => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</div>
)
return <div className="App">it works!</div>;
}
15 changes: 0 additions & 15 deletions src/favicon.svg

This file was deleted.

13 changes: 0 additions & 13 deletions src/index.css

This file was deleted.

7 changes: 0 additions & 7 deletions src/logo.svg

This file was deleted.

13 changes: 7 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import App from './App'
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
);

/* istanbul ignore file */
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@components/*": ["components/*"],
"@pages/*": ["pages/*"],
"@routes/*": ["routes/*"],
"@utils/*": ["utils/*"],
"@hooks/*": ["hooks/*"],
"@types/*": ["types/*"],
"@services/*": ["services/*"],
"@assets/*": ["assets/*"]
},
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["cypress", "node", "@testing-library/cypress"],
Expand Down
19 changes: 16 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 3000,
host: true,
},
resolve: {
alias: {
'@': '/src',
'@components': '/src/components',
'@pages': '/src/pages',
'@routes': '/src/routes',
'@utils': '/src/utils',
'@hooks': '/src/hooks',
'@assets': '/src/assets',
'@types': '/src/types',
'@services': '/src/services',
},
},
plugins: [react()],
})
});

0 comments on commit 560e745

Please sign in to comment.