Skip to content

Commit 37e5620

Browse files
authored
Merge pull request #1377 from yuvipanda/eslint
Lint our JS with a generous eslint
2 parents 655c6f5 + b165c74 commit 37e5620

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed

.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"jquery": true,
5+
"es6": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"sourceType": "module"
10+
},
11+
"rules": {
12+
}
13+
};

.github/workflows/eslint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Lints the binderhub/static/js folders content with eslint, influenced by
2+
# ".eslintrc.js", by running "npm run lint".
3+
name: eslint
4+
5+
on:
6+
pull_request:
7+
push:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Install modules
16+
run: npm i
17+
- name: Run ESLint on binderhub JS
18+
run: npm run lint

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ user interface of those parts as BinderHub is configured to fake those actions.
9797
You can tell you are using the fake builder and launcher from the fact that the
9898
build will never complete.
9999

100+
We use [eslint](https://eslint.org/) to catch errors in our JS, and you can
101+
run it locally with `npm run lint`.
102+
100103
To learn how to set yourself with a BinderHub development environment that lets
101104
you modify the builder and launcher refer to [Develop Kubernetes
102105
integration](#develop-kubernetes-integration) or [Develop Helm

binderhub/static/js/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function updateUrls(formValues) {
138138
$('#markdown-badge-snippet').text(markdownBadge(url));
139139
$('#rst-badge-snippet').text(rstBadge(url));
140140
} else {
141-
['#basic-url-snippet', '#markdown-badge-snippet', '#rst-badge-snippet' ].map(function(item, ind){
141+
['#basic-url-snippet', '#markdown-badge-snippet', '#rst-badge-snippet' ].map(function(item){
142142
const el = $(item);
143143
el.text(el.attr('data-default'));
144144
})
@@ -170,20 +170,20 @@ function build(providerSpec, log, fitAddon, path, pathType) {
170170
}
171171
});
172172

173-
image.onStateChange('waiting', function(oldState, newState, data) {
173+
image.onStateChange('waiting', function() {
174174
$('#phase-waiting').removeClass('hidden');
175175
});
176176

177-
image.onStateChange('building', function(oldState, newState, data) {
177+
image.onStateChange('building', function() {
178178
$('#phase-building').removeClass('hidden');
179179
log.show();
180180
});
181181

182-
image.onStateChange('pushing', function(oldState, newState, data) {
182+
image.onStateChange('pushing', function() {
183183
$('#phase-pushing').removeClass('hidden');
184184
});
185185

186-
image.onStateChange('failed', function(oldState, newState, data) {
186+
image.onStateChange('failed', function() {
187187
$('#build-progress .progress-bar').addClass('hidden');
188188
$('#phase-failed').removeClass('hidden');
189189

@@ -199,7 +199,7 @@ function build(providerSpec, log, fitAddon, path, pathType) {
199199
image.close();
200200
});
201201

202-
image.onStateChange('built', function(oldState, newState, data) {
202+
image.onStateChange('built', function(oldState) {
203203
if (oldState === null) {
204204
$('#phase-already-built').removeClass('hidden');
205205
$('#phase-launching').removeClass('hidden');
@@ -296,11 +296,11 @@ function indexMain() {
296296
updatePathText();
297297
updateRepoText();
298298

299-
$('#repository').on('keyup paste change', function(event) {updateUrls();});
299+
$('#repository').on('keyup paste change', function() {updateUrls();});
300300

301-
$('#ref').on('keyup paste change', function(event) {updateUrls();});
301+
$('#ref').on('keyup paste change', function() {updateUrls();});
302302

303-
$('#filepath').on('keyup paste change', function(event) {updateUrls();});
303+
$('#filepath').on('keyup paste change', function() {updateUrls();});
304304

305305
$('#toggle-badge-snippet').on('click', function() {
306306
const badgeSnippets = $('#badge-snippets');

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
"description": "`BinderHub`",
55
"devDependencies": {
66
"css-loader": "^6.2.0",
7+
"eslint": "^7.32.0",
78
"mini-css-extract-plugin": "^2.3.0",
89
"webpack": "^5.52.1",
910
"webpack-cli": "^4.8.0"
1011
},
1112
"dependencies": {
12-
"event-source-polyfill": "^1.0.25",
1313
"bootstrap": "^3.4.0",
1414
"clipboard": "^2.0.8",
1515
"jquery": "^3.6.0",
16+
"event-source-polyfill": "^1.0.25",
1617
"xterm": "^4.14.1",
1718
"xterm-addon-fit": "^0.5.0"
1819
},
1920
"scripts": {
2021
"webpack": "webpack",
21-
"webpack:watch": "webpack --watch"
22+
"webpack:watch": "webpack --watch",
23+
"lint": "eslint binderhub/static/js"
2224
},
2325
"repository": {
2426
"type": "git",

0 commit comments

Comments
 (0)