Skip to content

Commit

Permalink
Prettier; eslint. Closes #884
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Dec 15, 2024
1 parent 55d39d3 commit 3fab83b
Show file tree
Hide file tree
Showing 267 changed files with 4,458 additions and 3,608 deletions.
148 changes: 64 additions & 84 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,86 +1,66 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"plugins": [
"react"
],
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"semi": [
2,
"always"
],
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"object-curly-spacing": [
"error",
"always"
],
"allowIndentationTabs": 0,
"no-extra-parens": [
"off"
],
"max-len": [
"off"
],
"no-multi-spaces": "error",
"react/prop-types": [
"off"
],
"comma-dangle": "off",
"no-tabs": "off",
"no-multiple-empty-lines": "off",
"no-plusplus": "off",
"import/no-unresolved": "off",
"arrow-body-style": "off",
"import/extensions": "off",
"import/prefer-default-export": "off",
"lines-between-class-members": "off",
"object-curly-newline": "off",
"quotes": ["error", "single"],
"import/no-mutable-exports": "off",
"react/no-unused-prop-types": "off",
"react/no-unescaped-entities": "off",
"react/jsx-indent": [
2,
"tab"
],
"react/jsx-indent-props": [
2,
"tab"
],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off"
},
"settings": {
"react": {
"version": "16.8"
}
}
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"plugins": ["react"],
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"semi": [2, "always"],
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"object-curly-spacing": ["error", "always"],
"allowIndentationTabs": 0,
"no-extra-parens": ["off"],
"max-len": ["warn", { "code": 120 }],
"no-multi-spaces": "error",
"react/prop-types": ["off"],
"comma-dangle": "off",
"no-tabs": "off",
"no-multiple-empty-lines": "off",
"no-plusplus": "off",
"import/no-unresolved": "off",
"arrow-body-style": "off",
"import/extensions": "off",
"import/prefer-default-export": "off",
"lines-between-class-members": "off",
"object-curly-newline": "off",
"quotes": ["error", "single"],
"import/no-mutable-exports": "off",
"react/no-unused-prop-types": "off",
"react/no-unescaped-entities": "off",
"react/jsx-indent": [2, "tab"],
"react/jsx-indent-props": [2, "tab"],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off"
},
"settings": {
"react": {
"version": "16.13.1"
}
}
}
3 changes: 3 additions & 0 deletions .prettier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"print-width": 999
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"files.autoSave": "onFocusChange",
"vs-code-prettier-eslint.prettierLast": false,
"editor.tabSize": 2
}
37 changes: 16 additions & 21 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version 4 of generatedata uses Docker to simplify packaging up the app for devel
wasn't quite the wonder that I hoped it would be, but the benefits overall are undeniable.

I experimented with getting the dev environment running _entirely_ within Docker containers so you wouldn't require
to install anything locally, but I found it was simply too slow to be of practical use as a dev env. So instead, the
to install anything locally, but I found it was simply too slow to be of practical use as a dev env. So instead, the
local dev env just uses docker containers for the _server and database_; the FE code is still ran locally. I know that's
a pain for non-frontend developers especially who aren't so familiar with setting up NVM, Grunt etc., but it's a
trade-off I had to make.
Expand All @@ -15,43 +15,41 @@ trade-off I had to make.
- [NVM](https://github.com/nvm-sh/nvm#installing-and-updating) - namely node 12.
- Grunt CLI (`npm install grunt-cli -g`)


### Running dev environment

- `git clone https://github.com/benkeen/generatedata.git` - this clones the repo to your local computer. On Mac, I'd
suggest putting it in your `~` folder; I tried it in other locations but Docker ran into permissions issues.
suggest putting it in your `~` folder; I tried it in other locations but Docker ran into permissions issues.

- `nvm install`
- assuming your have NVM installed (see above), this'll choose the right node version. If not, just choose the
right node version specified in the `.nvmrc` file. If you're not running the correct version of node it will

- assuming your have NVM installed (see above), this'll choose the right node version. If not, just choose the
right node version specified in the `.nvmrc` file. If you're not running the correct version of node it will
throw an error during startup.

- `yarn install`
- After starting Docker, in one tab run: `yarn startAndBuildDevServer` - this boots up the server + database containers.
For subsequent runs you can just use `yarn startDevServer` and it'll be faster.
- In a second tab, `yarn start` - this boots up the client-side code. Be warned: this does a *LOT* of stuff and the
first time you run it it'll take a very long time to run.
- After starting Docker, in one tab run: `yarn startAndBuildDevServer` - this boots up the server + database containers.
For subsequent runs you can just use `yarn startDevServer` and it'll be faster.
- In a second tab, `yarn start` - this boots up the client-side code. Be warned: this does a _LOT_ of stuff and the
first time you run it it'll take a very long time to run.

After running the second command it should open up `http://localhost:9000` in your browser.


#### Shutting down dev env

`yarn stopDevServer` - shuts down docker.

I've found that sometimes that command chokes and you have to wait a few minutes before it runs properly. Presumably
it's because the docker container was still in the process of booting up. If there are still problems, you might want to just run
`yarn dockerCleanup`. I do this on the live server every time I update it. It completely clears everything out so you
can start from scratch. It WON'T, however, delete your
`yarn dockerCleanup`. I do this on the live server every time I update it. It completely clears everything out so you
can start from scratch. It WON'T, however, delete your

### Troubleshooting

> ERROR: for db Cannot start service db: error while creating mount source path '/host_mnt/xxx/data/db': mkdir /host_mnt/Users/xxx/data/db: no such file or directory
ERROR: Encountered errors while bringing up the project.
> ERROR: Encountered errors while bringing up the project.
Restarting Docker seemed to fix this. I did that via the UI tool.


## Locale file helpers

There are a several grunt helper functions for validation and managing the locale files. It's important to keep the files
Expand All @@ -66,31 +64,28 @@ These are found in `src/i18n`. They contain all the core i18n files.
- `grunt removeI18nKey --key=xxx` - where xxx is the property name.
- `grunt sortI18nFiles` - sorts the keys of all i18n files alphabetically.


### Text rules:

- titles, headings: capitalize every letter
- tooltips: sentence case, no ending period


### Building

Local dev, general steps:

- `yarn prodAllBuild` -
- `yarn prodAll` -
- `yarn startDevServer` -


### Common problems

#### Logging in with Google works but logs out when page is refreshed

If you find that after logging in with Google it gets lost after refreshing the page, check your system clock. The
If you find that after logging in with Google it gets lost after refreshing the page, check your system clock. The
OAuth2Client lib we're using uses the system clock when re-validating the google auth info. My own computer locally
(an 2017 Mac) when I leave it on for too long the time gets very out of whack, causing this problem. Restarting the
(an 2017 Mac) when I leave it on for too long the time gets very out of whack, causing this problem. Restarting the
computer (which restarts the clock) fixes it.

#### M1 mac
#### M1 mac

After upgrading to Ventura, I found I had problems running Docker.

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[![Build Status](https://travis-ci.com/benkeen/generatedata.svg?branch=master)](https://travis-ci.com/benkeen/generatedata)

This is the repo for the downloadable version of [generatedata.com](https://generatedata.com). The script is essentially
an *engine* to generate any sort of random data in any format. It currently comes with 30 or
so *Data Types* (types of data it generates), 12 *Export Types* (formats for the data, like CSV, SQL, JSON), plus
an _engine_ to generate any sort of random data in any format. It currently comes with 30 or
so _Data Types_ (types of data it generates), 12 _Export Types_ (formats for the data, like CSV, SQL, JSON), plus
around 32 data sets for specific countries (city names, regions etc). But more importantly it can be extended in any
way you want. Check out the [developer documentation](https://benkeen.github.io/generatedata/developerdoc/intro/) for more
information on that.
Expand All @@ -15,13 +15,14 @@ The current major version of the script is 4.x, which was a big change over earl
in PHP and MYSQL and 3.x offered a REST API to let you generate the data programmatically rather than via an API. While this is
still planned for 4.x it's not currently offered, and the plan it to tackle that _after_ making the script available
as an npm package - which we feel will be a more convenient way to programmatically generate data over the more agnostic
REST approach.
REST approach.
`

## Requirements

- Docker
- node
- nvm
- nvm

See the [Installation instructions](https://benkeen.github.io/generatedata/userdoc/installation/intro) for full details.

Expand All @@ -40,6 +41,5 @@ contributors agree that all code is released under this license.
In addition to the many fine folk who submit bug reports, a big thanks to the following for their help extending the script:
https://github.com/benkeen/generatedata/graphs/contributors


Ben Keen
[@vancouverben](https://twitter.com/#!/vancouverben)
6 changes: 1 addition & 5 deletions client/src/components/Buttons.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export const StyledPreviewPanelButton = withStyles({
})(Button);

export const PreviewPanelButton = ({ children, ...props }: ButtonProps): JSX.Element => (
<StyledPreviewPanelButton
color="primary"
variant="outlined"
size="medium"
{...props}>
<StyledPreviewPanelButton color="primary" variant="outlined" size="medium" {...props}>
{children}
</StyledPreviewPanelButton>
);
4 changes: 1 addition & 3 deletions client/src/components/Link.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const Link = ({ url, children = null, offSite = false }: LinkParams): JSX.Elemen
props.rel = 'noopener noreferrer';
}

return (
<a {...props}>{children ? children : url}</a>
);
return <a {...props}>{children ? children : url}</a>;
};

export default Link;
6 changes: 1 addition & 5 deletions client/src/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import React from 'react';
import MuiPagination from '@material-ui/lab/Pagination';

const Pagination = ({ numPages, currentPage, onChange }: any): JSX.Element => (
<MuiPagination
count={numPages}
page={currentPage}
onChange={onChange}
/>
<MuiPagination count={numPages} page={currentPage} onChange={onChange} />
);

export default Pagination;
5 changes: 1 addition & 4 deletions client/src/components/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import usePortal from '../hooks/usePortal';

const Portal = ({ id, children }: any): ReactPortal => {
const target = usePortal(id);
return createPortal(
children,
target
);
return createPortal(children, target);
};

export default Portal;
Loading

0 comments on commit 3fab83b

Please sign in to comment.