Skip to content

Commit 22ef53e

Browse files
committed
chore: linting with black, flake8, stylelint, and eslint/prettier
1 parent 671dbf7 commit 22ef53e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+8616
-5685
lines changed

.babelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"sourceType": "unambiguous",
3-
"plugins": ["@babel/plugin-transform-runtime"],
43
"presets": [
54
["@babel/env", {
65
"loose": true,

.editorconfig

Lines changed: 0 additions & 13 deletions
This file was deleted.

.eslintrc.js

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,29 @@
1+
/* eslint-disable */
12
module.exports = {
2-
'extends': [
3-
'airbnb-base/legacy',
3+
"extends": [
4+
"plugin:prettier/recommended"
45
],
5-
'parserOptions': {
6-
'sourceType': 'module',
7-
'ecmaVersion': 2017,
6+
"parser": "@babel/eslint-parser",
7+
"parserOptions": {
8+
"sourceType": "module",
9+
"ecmaVersion": 2018,
810
},
9-
'env': {
10-
'node': true,
11-
'es6': true,
12-
},
13-
"rules": {
14-
// The one assertion of personal preference: no spaces before parentheses
15-
// of anonymous functions
16-
'space-before-function-paren': ['error', {
17-
anonymous: 'never',
18-
named: 'never',
19-
asyncArrow: 'always',
20-
}],
21-
// Temporarily disabled rules
22-
//
23-
// no-use-before-define is a good rule, but it would make the diff for
24-
// linting the code even more inscrutible than it already is.
25-
'no-use-before-define': 'off',
26-
// Relax some rules
27-
'no-cond-assign': ['error', 'except-parens'],
28-
'no-unused-vars': ['error', {
29-
'args': 'none',
30-
}],
31-
// Disable some overly-strict airbnb style rules
32-
'no-underscore-dangle': 'off',
33-
'no-param-reassign': 'off',
34-
'class-methods-use-this': 'off',
35-
'function-paren-newline': 'off',
36-
'no-plusplus': 'off',
37-
'object-curly-spacing': 'off',
38-
'no-multi-assign': 'off',
39-
'no-else-return': 'off',
40-
// While technically useless from the point of view of the regex parser,
41-
// escaping characters inside character classes is more consistent. I
42-
// would say that they make the regular expression more readable, if the
43-
// idea of readable regular expressions wasn't absurd on its face.
44-
'no-useless-escape': 'off',
45-
// I'm inclined to reverse this rule to be ['error', 'always'], but not just yet
46-
// IE 8 is a thing of the past and trailing commas are useful.
47-
'comma-dangle': 'off',
48-
},
49-
'globals': {
50-
'django': false,
51-
'grappelli': false
11+
"env": {
12+
"es6": true,
13+
"browser": true
5214
},
15+
"overrides": [
16+
{
17+
"files": ["webpack.config.js"],
18+
"env": {
19+
"node": true
20+
},
21+
},
22+
],
23+
"ignorePatterns": [
24+
"nested_admin/static/nested_admin/dist/",
25+
"node_modules/",
26+
".tox",
27+
"venv*"
28+
],
5329
};

.github/workflows/test.yml

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
uses: actions/cache@v2
6565
with:
6666
path: nested_admin/tests/static
67-
key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'frontend/**') }}
67+
key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'nested_admin/static/nested_admin/src/**/*.*s') }}
6868

6969
- name: Cache node_modules
7070
id: cache-node_modules
@@ -73,19 +73,20 @@ jobs:
7373
path: node_modules
7474
key: node_modules-${{ hashFiles('package-lock.json') }}
7575

76-
- name: Setup nodejs 14
77-
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
78-
uses: actions/setup-node@v2
76+
- name: Setup nodejs
77+
if: steps.cache-test-dist.outputs.cache-hit != 'true'
78+
uses: actions/setup-node@v3
7979
with:
80-
node-version: '14'
80+
node-version: '16'
81+
cache: 'npm'
8182

8283
- name: npm ci
83-
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
84+
if: steps.cache-test-dist.outputs.cache-hit != 'true' && steps.cache-node_modules.outputs.cache-hit != 'true'
8485
run: |
8586
npm ci || npm ci || npm ci
8687
8788
- name: Build instrumented static files
88-
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
89+
if: steps.cache-test-dist.outputs.cache-hit != 'true'
8990
run: |
9091
npm run build
9192
@@ -115,6 +116,76 @@ jobs:
115116
env:
116117
CODECOV_NAME: ${{ github.workflow }}
117118

119+
lint:
120+
runs-on: ubuntu-latest
121+
strategy:
122+
fail-fast: false
123+
matrix:
124+
tool: ["flake8", "black", "eslint", "stylelint"]
125+
include:
126+
- tool: flake8
127+
language: python
128+
- tool: black
129+
language: python
130+
- tool: eslint
131+
language: javascript
132+
- tool: stylelint
133+
language: javascript
134+
135+
steps:
136+
- uses: actions/checkout@v2
137+
138+
- uses: actions/setup-python@v2
139+
if: matrix.language == 'python'
140+
with:
141+
python-version: 3.9
142+
143+
- name: Cache node_modules
144+
if: matrix.language == 'javascript'
145+
id: cache-node_modules
146+
uses: actions/cache@v2
147+
with:
148+
path: node_modules
149+
key: node_modules-${{ hashFiles('package-lock.json') }}-lint
150+
restore-keys: |
151+
node_modules-${{ hashFiles('package-lock.json') }}
152+
153+
- name: Setup nodejs
154+
if: matrix.language == 'javascript'
155+
uses: actions/setup-node@v3
156+
with:
157+
node-version: '16'
158+
cache: 'npm'
159+
160+
- name: npm ci
161+
if: matrix.language == 'javascript' && steps.cache-node_modules.outputs.cache-hit != 'true'
162+
run: |
163+
npm ci || npm ci || npm ci
164+
165+
- name: Run black
166+
if: matrix.tool == 'black'
167+
uses: psf/black@stable
168+
with:
169+
src: "nested_admin docs setup.py"
170+
version: "22.8.0"
171+
172+
- name: Install flake8
173+
if: matrix.tool == 'flake8'
174+
run: pip install flake8
175+
176+
- name: Run flake8
177+
if: matrix.tool == 'flake8'
178+
uses: suo/flake8-github-action@releases/v1
179+
with:
180+
checkName: 'lint'
181+
env:
182+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
183+
184+
- name: Run ${{ matrix.tool }}
185+
if: matrix.language == 'javascript'
186+
run: |
187+
npm run lint:${{ matrix.tool }}
188+
118189
report:
119190
if: always()
120191
needs: build
@@ -126,16 +197,15 @@ jobs:
126197
name: junit-reports
127198

128199
- name: Publish tests report
129-
uses: mikepenz/action-junit-report@5703ba1461f35871cde0208140d737d3e1eef38f
200+
uses: mikepenz/action-junit-report@1a91e26932fb7ba410a31fab1f09266a96d29971
130201
with:
131202
report_paths: ./*.xml
132-
github_token: ${{ secrets.GITHUB_TOKEN }}
133203
require_tests: true
134204
fail_on_failure: true
135205
check_name: Test Report
136206

137207
success:
138-
needs: report
208+
needs: [lint, report]
139209
runs-on: ubuntu-latest
140210
name: Test Successful
141211
steps:

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

.stylelintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/nested_admin/tests/static
2+
/nested_admin/static/nested_admin/dist
3+
node_modules
4+
venv
5+
.tox
6+
**/*.js
7+
**/*.html
8+
**/*.xml

.stylelintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": [
3+
"stylelint-config-recommended-scss",
4+
"stylelint-prettier/recommended"
5+
],
6+
"overrides": [{
7+
"files": ["**/*.scss"],
8+
"customSyntax": "postcss-scss"
9+
}]
10+
}

docs/conf.py

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from datetime import datetime
55

66

7-
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
88

9-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
9+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
1010

11-
os.environ['DJANGO_SETTINGS_MODULE'] = 'nested_admin.tests.settings'
11+
os.environ["DJANGO_SETTINGS_MODULE"] = "nested_admin.tests.settings"
1212

1313

1414
import django # noqa
@@ -19,63 +19,80 @@
1919
django.setup()
2020

2121

22-
project = 'django-nested-admin'
23-
copyright = '%d, The Atlantic' % datetime.now().year
24-
author = 'The Atlantic'
22+
project = "django-nested-admin"
23+
copyright = "%d, The Atlantic" % datetime.now().year
24+
author = "The Atlantic"
2525

2626
release = pkg_resources.get_distribution(project).version
27-
version = '.'.join(release.split('.')[:2])
27+
version = ".".join(release.split(".")[:2])
2828

2929
extensions = [
30-
'sphinx.ext.autodoc',
31-
'sphinx.ext.mathjax',
30+
"sphinx.ext.autodoc",
31+
"sphinx.ext.mathjax",
3232
"sphinx.ext.intersphinx",
3333
"sphinx.ext.viewcode",
3434
]
3535

3636

3737
def setup(app):
38-
app.add_stylesheet('nested_admin.css')
38+
app.add_stylesheet("nested_admin.css")
3939

4040

41-
templates_path = ['_templates']
42-
source_suffix = '.rst'
43-
master_doc = 'index'
41+
templates_path = ["_templates"]
42+
source_suffix = ".rst"
43+
master_doc = "index"
4444
language = None
4545

46-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
46+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4747
add_function_parentheses = True
4848
add_module_names = False
49-
pygments_style = 'trac'
49+
pygments_style = "trac"
5050
todo_include_todos = False
5151

52-
html_theme = 'default'
53-
html_static_path = ['_static']
54-
html_last_updated_fmt = '%b %d, %Y'
52+
html_theme = "default"
53+
html_static_path = ["_static"]
54+
html_last_updated_fmt = "%b %d, %Y"
5555
html_show_sphinx = False
5656

57-
htmlhelp_basename = 'django-nested-admindoc'
57+
htmlhelp_basename = "django-nested-admindoc"
5858

5959
latex_elements = {}
6060
latex_documents = [
61-
(master_doc, 'django-nested-admin.tex', 'django-nested-admin Documentation',
62-
'The Atlantic', 'manual'),
61+
(
62+
master_doc,
63+
"django-nested-admin.tex",
64+
"django-nested-admin Documentation",
65+
"The Atlantic",
66+
"manual",
67+
),
6368
]
6469

6570
man_pages = [
66-
(master_doc, 'django-nested-admin', 'django-nested-admin Documentation',
67-
[author], 1)
71+
(
72+
master_doc,
73+
"django-nested-admin",
74+
"django-nested-admin Documentation",
75+
[author],
76+
1,
77+
)
6878
]
6979

7080
texinfo_documents = [
71-
(master_doc, 'django-nested-admin', 'django-nested-admin Documentation',
72-
author, 'django-nested-admin', 'One line description of project.',
73-
'Miscellaneous'),
81+
(
82+
master_doc,
83+
"django-nested-admin",
84+
"django-nested-admin Documentation",
85+
author,
86+
"django-nested-admin",
87+
"One line description of project.",
88+
"Miscellaneous",
89+
),
7490
]
7591

7692
if not on_rtd: # only import and set the theme if we're building docs locally
77-
extensions.insert(0, 'readthedocs_ext.readthedocs')
93+
extensions.insert(0, "readthedocs_ext.readthedocs")
7894

7995
import sphinx_rtd_theme
80-
html_theme = 'sphinx_rtd_theme'
96+
97+
html_theme = "sphinx_rtd_theme"
8198
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

0 commit comments

Comments
 (0)