Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
hubert / Running husky prettier (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
hubert-deriv authored Nov 17, 2022
1 parent 91b0512 commit fec2c97
Show file tree
Hide file tree
Showing 104 changed files with 3,394 additions and 3,643 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
public/demos/demos/*
tsconfig.json
tsconfig.node.json
state/state.js
209 changes: 102 additions & 107 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,116 +1,111 @@
/* eslint-disable */
module.exports = {
env: {
browser: true,
es6: true,
es2021: true,
node: true,
cypress: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
env: {
browser: true,
es6: true,
es2021: true,
node: true,
},
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["react", "@typescript-eslint"],
rules: {
"react/react-in-jsx-scope": "off",
camelcase: 0,
// semi : ["error", "always"],
"array-callback-return": 0,
"arrow-body-style": 0,
"brace-style": ["error", "1tbs", { allowSingleLine: true }],
curly: 0,
// "comma-dangle" : ["error", "always-multiline"],
"eol-last": ["error", "always"],
"func-names": ["error", "never"],
"key-spacing": 0,
"max-classes-per-file": ["warn", 2],
// "keyword-spacing" : ["error", { after: true }],
"lines-between-class-members": 0,
indent: 0,
// "max-len": ["error", { code: 120, "ignoreComments": true }],
"no-extra-semi": "error",
"no-console": "error",
"no-else-return": ["error", { allowElseIf: true }],
"no-multi-assign": 0,
"no-multi-spaces": [
2,
{
exceptions: {
BinaryExpression: true,
VariableDeclarator: true,
ImportDeclaration: true,
},
},
],
"no-param-reassign": ["error", { props: false }],
"no-restricted-globals": 0,
"no-script-url": 0,
// "no-trailing-spaces" : ["error", { skipBlankLines: true }],
"object-curly-spacing": [
"error",
"always",
{ arraysInObjects: true, objectsInObjects: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
"one-var": ["error", { initialized: "never", uninitialized: "always" }],
"prefer-destructuring": 0,
quotes: 0,
// "space-in-parens" : ["error", "never"],
"space-infix-ops": "error",
// "space-unary-ops" : "error",
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
rules: {
'react/react-in-jsx-scope': 'off',
camelcase: 0,
// semi : ["error", "always"],
'array-callback-return': 0,
'arrow-body-style': 0,
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
curly: 0,
// "comma-dangle" : ["error", "always-multiline"],
'eol-last': ['error', 'always'],
'func-names': ['error', 'never'],
'key-spacing': 0,
'max-classes-per-file': ['warn', 2],
// "keyword-spacing" : ["error", { after: true }],
'lines-between-class-members': 0,
indent: 0,
// "max-len": ["error", { code: 120, "ignoreComments": true }],
'no-extra-semi': 'error',
'no-console': 'error',
'no-else-return': ['error', { allowElseIf: true }],
'no-multi-assign': 0,
'no-multi-spaces': [
2,
{
exceptions: {
BinaryExpression: true,
VariableDeclarator: true,
ImportDeclaration: true,
},
},
],
'no-param-reassign': ['error', { props: false }],
'no-restricted-globals': 0,
'no-script-url': 0,
// "no-trailing-spaces" : ["error", { skipBlankLines: true }],
'object-curly-spacing': ['error', 'always', { arraysInObjects: true, objectsInObjects: true }],
'one-var': ['error', { initialized: 'never', uninitialized: 'always' }],
'prefer-destructuring': 0,
quotes: 0,
// "space-in-parens" : ["error", "never"],
'space-infix-ops': 'error',
// "space-unary-ops" : "error",
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],

// import rules
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: [
"**/__tests__/**/*.js",
"**/test*.js",
"**/*.test.js*",
"**/*.spec.js",
"**/*.spec.jsx",
// import rules
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/__tests__/**/*.js',
'**/test*.js',
'**/*.test.js*',
'**/*.spec.js',
'**/*.spec.jsx',
],
},
],
},
],

"import/no-useless-path-segments": "error",
"import/order": [
0, // TODO: we should turn this to error after we sorted our import orders.
{
groups: [["builtin", "external"], "internal", "sibling", "parent"],
"newlines-between": "ignore",
},
],
"import/prefer-default-export": 0,
"import/extensions": ["warn", "never", { jsx: "never", json: "always" }],
"no-sequences": ["warn"],
'import/no-useless-path-segments': 'error',
'import/order': [
0, // TODO: we should turn this to error after we sorted our import orders.
{
groups: [['builtin', 'external'], 'internal', 'sibling', 'parent'],
'newlines-between': 'ignore',
},
],
'import/prefer-default-export': 0,
'import/extensions': ['warn', 'never', { jsx: 'never', json: 'always' }],
'no-sequences': ['warn'],

// react rules
// "jsx-quotes" : ["error", "prefer-single"],
// "react/jsx-closing-bracket-location": ["error", { selfClosing: "line-aligned", nonEmpty: "line-aligned" }],
// "react/jsx-closing-tag-location" : "error",
// "react/jsx-first-prop-new-line" : ["error", "multiline-multiprop"],
// "react/jsx-indent" : ["error", 4],
// "react/jsx-indent-props" : ["error", 4],
// "react/jsx-max-props-per-line" : ["error", { when: "multiline" }],
// "react/jsx-tag-spacing" : ["error", { closingSlash: "never", beforeSelfClosing: "always" }],
"react/prop-types": 0,
"react/self-closing-comp": "error",
"react/no-unescaped-entities": 0,
// "react/sort-prop-types" : ["error", { ignoreCase: true, sortShapeProp: true }],
},
// react rules
// "jsx-quotes" : ["error", "prefer-single"],
// "react/jsx-closing-bracket-location": ["error", { selfClosing: "line-aligned", nonEmpty: "line-aligned" }],
// "react/jsx-closing-tag-location" : "error",
// "react/jsx-first-prop-new-line" : ["error", "multiline-multiprop"],
// "react/jsx-indent" : ["error", 4],
// "react/jsx-indent-props" : ["error", 4],
// "react/jsx-max-props-per-line" : ["error", { when: "multiline" }],
// "react/jsx-tag-spacing" : ["error", { closingSlash: "never", beforeSelfClosing: "always" }],
'react/prop-types': 0,
'react/self-closing-comp': 'error',
'react/no-unescaped-entities': 0,
// "react/sort-prop-types" : ["error", { ignoreCase: true, sortShapeProp: true }],
},
};
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run format
13 changes: 12 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,15 @@ _site/
_data/
config/
examples/
public/
public/
api-data/
state.js
*.d.ts
*.config.ts
*.config.js
*.config.tsx
*.config.json
*.tsconfig.json
*.tsconfig.node.json
README.md
vercel.json
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ Moreover, having these extensions will help you to speed up the development proc
npm install
```


5. **To start developing:**

```sh
npm run dev
```

1. Release to staging:
1. Release to staging:

Merging to master (squash and merge) will automatically release the last commit to the staging server https://staging-api.deriv.com/

Expand All @@ -67,7 +66,7 @@ Releasing to production requires a tag using the following format:

## How to contribute

PRs are based on the master branch
PRs are based on the master branch

1. Create branch from the latest master branch

Expand All @@ -89,4 +88,4 @@ PRs are based on the master branch

## Test link deployment

Upon creating PR, [Vercel](https://vercel.com/) will auto-generate a test link inside the PR. you can use that to preview the test link for the changes you have made.
Upon creating PR, [Vercel](https://vercel.com/) will auto-generate a test link inside the PR. you can use that to preview the test link for the changes you have made.
30 changes: 18 additions & 12 deletions cypress/e2e/api.deriv.com.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const derivAPIEvents = {
},
CLICK_LOGO: function () {
cy.get('[data-testid="home_logo"]').click();
}
},
};

const derivAPIStates = {
Expand All @@ -171,7 +171,9 @@ const derivAPIStates = {
cy.contains(/ways to earn with deriv api/i).should('be.visible');
cy.contains(/register your app with deriv/i).should('be.visible');
cy.contains(/sign up as an affiliate, build your app/i).should('be.visible');
cy.contains(/sign up as a payment agent/i).should('be.visible').scrollIntoView();
cy.contains(/sign up as a payment agent/i)
.should('be.visible')
.scrollIntoView();
},
playground: () => {
// checkScroll(); TODO children states cause scroll to not be at top
Expand All @@ -183,8 +185,12 @@ const derivAPIStates = {
},
documetnation: () => {
isScrollOnTop();
cy.contains(/Quickstart to Deriv API/i).should('be.visible').scrollIntoView();
cy.contains(/Keep alive/i).should('be.visible').scrollIntoView();
cy.contains(/Quickstart to Deriv API/i)
.should('be.visible')
.scrollIntoView();
cy.contains(/Keep alive/i)
.should('be.visible')
.scrollIntoView();
},
faq: () => {
isScrollOnTop();
Expand Down Expand Up @@ -218,25 +224,25 @@ const derivAPIStates = {
cy.get('[data-testid="apiTokenInput"]').should('have.value', Cypress.env('DERIV_API_TOKEN'));
},
displayAuthDoc: () => {
cy.get('[data-testid=apiDropdown]')
.contains(/authorize/i)
cy.get('[data-testid=apiDropdown]').contains(/authorize/i);
cy.get('[data-testid=playgroundDocs]')
.should('be.visible')
.contains(/authorize/i);
},
displaySelectedDoc: () => {
cy.get('[data-testid=apiDropdown]')
.contains(/authorize/i)
.should('not.exist');
.contains(/authorize/i)
.should('not.exist');
cy.get('[data-testid=playgroundDocs]')
.should('be.visible')
// should not contain authorize
.contains(/authorize/i).should('not.exist');
.should('be.visible')
// should not contain authorize
.contains(/authorize/i)
.should('not.exist');
},
selecting_api: () => {
// data-testid searchInput should be in focus
cy.get('[data-testid="searchInput"]').should('have.focus');
}
},
};

// cypress check if the scroll is at the top of the page
Expand Down
6 changes: 3 additions & 3 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint": "eslint .",
"lint:fix": "eslint --fix",
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc",
"e2e": "cypress open"
"e2e": "cypress open",
"prepare": "husky install"
},
"dependencies": {
"@cypress/code-coverage": "^3.10.0",
Expand Down
Loading

1 comment on commit fec2c97

@vercel
Copy link

@vercel vercel bot commented on fec2c97 Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-developers-portal – ./

deriv-developers-portal.binary.sx
deriv-developers-portal-git-master.binary.sx

Please sign in to comment.