add ESLint

This commit is contained in:
Daniel Waxweiler 2021-04-05 17:53:47 +02:00
parent 1e4d0c0a09
commit 0ee1d8cc18
7 changed files with 1422 additions and 9 deletions

31
.eslintrc.json Normal file
View File

@ -0,0 +1,31 @@
{
"env": {
"browser": true,
"es2020": true
},
"extends": [
"eslint:recommended",
"plugin:ava/recommended"
],
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": [
"ava"
],
"rules": {
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
}
}

View File

@ -28,5 +28,6 @@ More details can be found in the [WordPress Plugin Directory](https://wordpress.
10. Tag the new version in `git` too. 10. Tag the new version in `git` too.
### Other commands ### Other commands
- Run ESLint: `npm run eslint`
- Run tests: `npm test` - Run tests: `npm test`
- Delete build folder: `gulp clean` - Delete build folder: `gulp clean`

View File

@ -32,7 +32,7 @@ function bundleFrontend() {
}, },
})) }))
.pipe(dest(FOLDER_BUILD)); .pipe(dest(FOLDER_BUILD));
} }
function copyBackend() { function copyBackend() {
return src([ return src([

1390
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@
"scripts": { "scripts": {
"build-dev": "gulp dev", "build-dev": "gulp dev",
"build-prod": "ava && gulp prod", "build-prod": "ava && gulp prod",
"eslint": "npx eslint source/**/*.js",
"test": "ava" "test": "ava"
}, },
"author": { "author": {
@ -26,6 +27,8 @@
"devDependencies": { "devDependencies": {
"ava": "^3.15.0", "ava": "^3.15.0",
"del": "^6.0.0", "del": "^6.0.0",
"eslint": "^7.23.0",
"eslint-plugin-ava": "^12.0.0",
"esm": "^3.2.25", "esm": "^3.2.25",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-replace": "^1.0.0", "gulp-replace": "^1.0.0",

View File

@ -23,7 +23,7 @@ function displayEvents(data, list) {
dateText += ' ' + beginsOn.get24Time() dateText += ' ' + beginsOn.get24Time()
dateText += ' - ' dateText += ' - '
if (!beginsOn.equalsDate(endsOn)) { if (!beginsOn.equalsDate(endsOn)) {
dateText += endsOn.getShortDate() + ' ' dateText += endsOn.getShortDate() + ' '
} }
dateText += endsOn.get24Time() dateText += endsOn.get24Time()
const textnode = document.createTextNode(dateText) const textnode = document.createTextNode(dateText)

View File

@ -11,5 +11,5 @@ test('createAnchorElement() usual parameters', t => {
const a = HtmlCreator.createAnchorElement({ text: 'a', url: 'b' }) const a = HtmlCreator.createAnchorElement({ text: 'a', url: 'b' })
t.is(a.tagName, 'A') t.is(a.tagName, 'A')
t.is(a.innerHTML, 'a') t.is(a.innerHTML, 'a')
t.is(a.getAttribute('href'), 'b') t.is(a.getAttribute('href'), 'b')
}) })