API & Client: pre-commit lint
This commit is contained in:
parent
f9a1768e64
commit
e1062a107c
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,7 +6,8 @@
|
|||||||
###############
|
###############
|
||||||
__pycache__
|
__pycache__
|
||||||
/mpwo_api/venv/
|
/mpwo_api/venv/
|
||||||
|
uploads
|
||||||
|
.cache
|
||||||
|
|
||||||
# MPWO_CLIENT
|
# MPWO_CLIENT
|
||||||
###############
|
###############
|
||||||
@ -31,4 +32,3 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
.eslintcache
|
.eslintcache
|
||||||
uploads
|
|
||||||
|
3
.isort.cfg
Normal file
3
.isort.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[settings]
|
||||||
|
multi_line_output=5
|
||||||
|
default_section=THIRDPARTY
|
8
Makefile
8
Makefile
@ -18,6 +18,14 @@ install-python:
|
|||||||
test -d $(VENV) || virtualenv $(VENV) -p $(PYTHON_VERSION)
|
test -d $(VENV) || virtualenv $(VENV) -p $(PYTHON_VERSION)
|
||||||
$(PIP) install -r $(REQUIREMENTS)
|
$(PIP) install -r $(REQUIREMENTS)
|
||||||
|
|
||||||
|
lint-all: lint-python lint-react
|
||||||
|
|
||||||
|
lint-python:
|
||||||
|
$(PYTEST) --flake8 --isort -m "flake8 or isort" mpwo_api
|
||||||
|
|
||||||
|
lint-react:
|
||||||
|
$(NPM) lint
|
||||||
|
|
||||||
serve-python:
|
serve-python:
|
||||||
$(FLASK) run --with-threads -h $(HOST) -p $(API_PORT)
|
$(FLASK) run --with-threads -h $(HOST) -p $(API_PORT)
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ VENV = $(PWD)/mpwo_api/venv
|
|||||||
PYTHON = $(VENV)/bin/python
|
PYTHON = $(VENV)/bin/python
|
||||||
PIP = $(VENV)/bin/pip
|
PIP = $(VENV)/bin/pip
|
||||||
FLASK = $(VENV)/bin/flask
|
FLASK = $(VENV)/bin/flask
|
||||||
|
PYTEST = $(VENV)/bin/py.test
|
||||||
|
|
||||||
# Node env
|
# Node env
|
||||||
NODE_MODULES = $(PWD)/mpwo_client/node_modules
|
NODE_MODULES = $(PWD)/mpwo_client/node_modules
|
||||||
|
@ -31,6 +31,7 @@ if app.debug:
|
|||||||
logging.getLogger('sqlalchemy'
|
logging.getLogger('sqlalchemy'
|
||||||
).handlers = logging.getLogger('werkzeug').handlers
|
).handlers = logging.getLogger('werkzeug').handlers
|
||||||
logging.getLogger('sqlalchemy.orm').setLevel(logging.WARNING)
|
logging.getLogger('sqlalchemy.orm').setLevel(logging.WARNING)
|
||||||
|
logging.getLogger('flake8').propagate = False
|
||||||
appLog.setLevel(logging.DEBUG)
|
appLog.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
if app.debug:
|
if app.debug:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from flask_testing import TestCase
|
from flask_testing import TestCase
|
||||||
|
|
||||||
from mpwo_api import app, db
|
from mpwo_api import app, db
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class TestAuthBlueprint(BaseTestCase):
|
|||||||
data = json.loads(response.data.decode())
|
data = json.loads(response.data.decode())
|
||||||
self.assertTrue(data['status'] == 'error')
|
self.assertTrue(data['status'] == 'error')
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
data['message'] == "Errors: Username: 3 to 12 characters required.\n")
|
data['message'] == "Errors: Username: 3 to 12 characters required.\n") # noqa
|
||||||
self.assertTrue(response.content_type == 'application/json')
|
self.assertTrue(response.content_type == 'application/json')
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ class TestAuthBlueprint(BaseTestCase):
|
|||||||
data = json.loads(response.data.decode())
|
data = json.loads(response.data.decode())
|
||||||
self.assertTrue(data['status'] == 'error')
|
self.assertTrue(data['status'] == 'error')
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
data['message'] == "Errors: Username: 3 to 12 characters required.\n")
|
data['message'] == "Errors: Username: 3 to 12 characters required.\n") # noqa
|
||||||
self.assertTrue(response.content_type == 'application/json')
|
self.assertTrue(response.content_type == 'application/json')
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class TestAuthBlueprint(BaseTestCase):
|
|||||||
data = json.loads(response.data.decode())
|
data = json.loads(response.data.decode())
|
||||||
self.assertTrue(data['status'] == 'error')
|
self.assertTrue(data['status'] == 'error')
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
data['message'] == "Errors: Valid email must be provided.\n")
|
data['message'] == "Errors: Valid email must be provided.\n") # noqa
|
||||||
self.assertTrue(response.content_type == 'application/json')
|
self.assertTrue(response.content_type == 'application/json')
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class TestAuthBlueprint(BaseTestCase):
|
|||||||
data = json.loads(response.data.decode())
|
data = json.loads(response.data.decode())
|
||||||
self.assertTrue(data['status'] == 'error')
|
self.assertTrue(data['status'] == 'error')
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
data['message'] == "Errors: Password: 8 characters required.\n")
|
data['message'] == "Errors: Password: 8 characters required.\n") # noqa
|
||||||
self.assertTrue(response.content_type == 'application/json')
|
self.assertTrue(response.content_type == 'application/json')
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class TestAuthBlueprint(BaseTestCase):
|
|||||||
data = json.loads(response.data.decode())
|
data = json.loads(response.data.decode())
|
||||||
self.assertTrue(data['status'] == 'error')
|
self.assertTrue(data['status'] == 'error')
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
data['message'] == "Errors: Password and password confirmation don\'t match.\n")
|
data['message'] == "Errors: Password and password confirmation don\'t match.\n") # noqa
|
||||||
self.assertTrue(response.content_type == 'application/json')
|
self.assertTrue(response.content_type == 'application/json')
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flask import Blueprint, current_app, jsonify, request
|
from flask import Blueprint, current_app, jsonify, request
|
||||||
|
from mpwo_api import appLog, bcrypt, db
|
||||||
from sqlalchemy import exc, or_
|
from sqlalchemy import exc, or_
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
from mpwo_api import appLog, bcrypt, db
|
|
||||||
|
|
||||||
from .models import User
|
from .models import User
|
||||||
from .utils import allowed_picture, authenticate, register_controls
|
from .utils import allowed_picture, authenticate, register_controls
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import datetime
|
|||||||
|
|
||||||
import jwt
|
import jwt
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from mpwo_api import bcrypt, db
|
from mpwo_api import bcrypt, db
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from functools import wraps
|
|
||||||
import re
|
import re
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
from flask import current_app, jsonify, request
|
from flask import current_app, jsonify, request
|
||||||
|
|
||||||
|
@ -18,6 +18,11 @@ psycopg2==2.7.3.2
|
|||||||
pycodestyle==2.3.1
|
pycodestyle==2.3.1
|
||||||
pycparser==2.18
|
pycparser==2.18
|
||||||
pyflakes==1.6.0
|
pyflakes==1.6.0
|
||||||
|
pytest==3.3.2
|
||||||
|
pytest-cache==1.0
|
||||||
|
pytest-flake8==0.9.1
|
||||||
|
pytest-isort==0.1.0
|
||||||
|
pytest-runner==3.0
|
||||||
PyJWT==1.5.3
|
PyJWT==1.5.3
|
||||||
six==1.11.0
|
six==1.11.0
|
||||||
SQLAlchemy==1.1.15
|
SQLAlchemy==1.1.15
|
||||||
|
@ -3,7 +3,11 @@ import { connect } from 'react-redux'
|
|||||||
import { Redirect } from 'react-router-dom'
|
import { Redirect } from 'react-router-dom'
|
||||||
|
|
||||||
import Form from './Form'
|
import Form from './Form'
|
||||||
import { emptyForm, handleFormChange, handleUserFormSubmit } from '../../actions'
|
import {
|
||||||
|
emptyForm,
|
||||||
|
handleFormChange,
|
||||||
|
handleUserFormSubmit
|
||||||
|
} from '../../actions'
|
||||||
import { isLoggedIn } from '../../utils'
|
import { isLoggedIn } from '../../utils'
|
||||||
|
|
||||||
class UserForm extends React.Component {
|
class UserForm extends React.Component {
|
||||||
|
59
package-lock.json
generated
59
package-lock.json
generated
@ -2761,11 +2761,6 @@
|
|||||||
"cssom": "0.3.2"
|
"cssom": "0.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cuid": {
|
|
||||||
"version": "2.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/cuid/-/cuid-2.0.2.tgz",
|
|
||||||
"integrity": "sha512-dzz/KESlvSRPnAoThLqxHGfW94rtPYrHpQ8OpT5WwfJVlhysPw1U989+3fHrn/FdtuMrFW5dzOVR/CAb90RbNw=="
|
|
||||||
},
|
|
||||||
"currently-unhandled": {
|
"currently-unhandled": {
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
|
||||||
@ -4404,7 +4399,8 @@
|
|||||||
},
|
},
|
||||||
"jsbn": {
|
"jsbn": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"json-schema": {
|
"json-schema": {
|
||||||
"version": "0.2.3",
|
"version": "0.2.3",
|
||||||
@ -5070,11 +5066,6 @@
|
|||||||
"minimalistic-assert": "1.0.0"
|
"minimalistic-assert": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hashids": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/hashids/-/hashids-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-U/fnTE3edW0AV92ZI/BfEluMZuVcu3MDOopsN7jS+HqDYcarQo8rXQiWlsBlm0uX48/taYSdxRsfzh2HRg5Z6w=="
|
|
||||||
},
|
|
||||||
"hawk": {
|
"hawk": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz",
|
||||||
@ -7381,6 +7372,12 @@
|
|||||||
"lcid": "1.0.0"
|
"lcid": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"os-shim": {
|
||||||
|
"version": "0.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz",
|
||||||
|
"integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"os-tmpdir": {
|
"os-tmpdir": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||||
@ -9435,6 +9432,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"pre-commit": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/pre-commit/-/pre-commit-1.2.2.tgz",
|
||||||
|
"integrity": "sha1-287g7p3nI15X95xW186UZBpp7sY=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"cross-spawn": "5.1.0",
|
||||||
|
"spawn-sync": "1.0.15",
|
||||||
|
"which": "1.2.14"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"which": {
|
||||||
|
"version": "1.2.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz",
|
||||||
|
"integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"isexe": "2.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"prelude-ls": {
|
"prelude-ls": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
|
||||||
@ -9796,14 +9815,6 @@
|
|||||||
"react-side-effect": "1.1.3"
|
"react-side-effect": "1.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-key-index": {
|
|
||||||
"version": "0.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-key-index/-/react-key-index-0.1.1.tgz",
|
|
||||||
"integrity": "sha1-gxnk8JYa5EqOsKT3bkwhDvbTnNo=",
|
|
||||||
"requires": {
|
|
||||||
"hashids": "1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-redux": {
|
"react-redux": {
|
||||||
"version": "5.0.6",
|
"version": "5.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.0.6.tgz",
|
||||||
@ -11646,6 +11657,16 @@
|
|||||||
"integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=",
|
"integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"spawn-sync": {
|
||||||
|
"version": "1.0.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz",
|
||||||
|
"integrity": "sha1-sAeZVX63+wyDdsKdROih6mfldHY=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"concat-stream": "1.6.0",
|
||||||
|
"os-shim": "0.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"spdx-correct": {
|
"spdx-correct": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz",
|
||||||
|
@ -21,14 +21,17 @@
|
|||||||
"build": "cd mpwo_client && react-scripts build",
|
"build": "cd mpwo_client && react-scripts build",
|
||||||
"test": "cd mpwo_client && testcafe firefox e2e",
|
"test": "cd mpwo_client && testcafe firefox e2e",
|
||||||
"eject": "cd mpwo_client && react-scripts eject",
|
"eject": "cd mpwo_client && react-scripts eject",
|
||||||
"lint": "cd mpwo_client && eslint --cache --ext .jsx --ext .js src"
|
"lint": "eslint --cache --ext .jsx --ext .js mpwo/src",
|
||||||
|
"lint-all": "make lint-all"
|
||||||
},
|
},
|
||||||
|
"pre-commit": "lint-all",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^8.0.3",
|
"babel-eslint": "^8.0.3",
|
||||||
"eslint": "^4.13.1",
|
"eslint": "^4.13.1",
|
||||||
"eslint-plugin-import": "^2.8.0",
|
"eslint-plugin-import": "^2.8.0",
|
||||||
"eslint-plugin-react": "^7.5.1",
|
"eslint-plugin-react": "^7.5.1",
|
||||||
"eslint-plugin-testcafe": "^0.2.1",
|
"eslint-plugin-testcafe": "^0.2.1",
|
||||||
|
"pre-commit": "^1.2.2",
|
||||||
"randomstring": "^1.1.5",
|
"randomstring": "^1.1.5",
|
||||||
"testcafe": "^0.18.6"
|
"testcafe": "^0.18.6"
|
||||||
}
|
}
|
||||||
|
2
pytest.ini
Normal file
2
pytest.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[pytest]
|
||||||
|
norecursedirs = mpwo_api/venv
|
Loading…
Reference in New Issue
Block a user