Add and configure eslint

This commit is contained in:
heyarne 2021-04-25 18:23:27 +02:00 committed by Georg Krause
parent 8202c1879b
commit 584471969e
No known key found for this signature in database
GPG Key ID: FD479B9A4D48E632
6 changed files with 15351 additions and 99 deletions

View File

@ -303,11 +303,13 @@ Typical workflow for a contribution
2. If working on an issue, assign yourself to the issue. Otherwise, consider open an issue before starting to work on something, especially for new features. 2. If working on an issue, assign yourself to the issue. Otherwise, consider open an issue before starting to work on something, especially for new features.
3. Create a dedicated branch for your work ``42-awesome-fix``. It is good practice to prefix your branch name with the ID of the issue you are solving. 3. Create a dedicated branch for your work ``42-awesome-fix``. It is good practice to prefix your branch name with the ID of the issue you are solving.
4. Work on your stuff 4. Work on your stuff
5. Commit small, atomic changes to make it easier to review your contribution 5. [Optional] Consider running ``yarn lint`` in ``front`` if you changed something there. Consider fixing some
6. Add a changelog fragment to summarize your changes: ``echo "Implemented awesome stuff (#42)" > changes/changelog.d/42.feature`` linting errors in the files you touched.
7. Push your branch 6. Commit small, atomic changes to make it easier to review your contribution
8. Create your merge request 7. Add a changelog fragment to summarize your changes: ``echo "Implemented awesome stuff (#42)" > changes/changelog.d/42.feature``
9. Take a step back and enjoy, we're really grateful you did all of this and took the time to contribute! 8. Push your branch
9. Create your merge request
10. Take a step back and enjoy, we're really grateful you did all of this and took the time to contribute!
Changelog management Changelog management
-------------------- --------------------

View File

@ -0,0 +1 @@
Add linting for Frontend code ()

23
front/.eslintrc.js Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
env: {
browser: true,
es6: true
},
extends: [
'plugin:vue/recommended',
'standard'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: [
'vue'
],
rules: {
}
}

15312
front/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
"serve": "[ ! -d src/translations ] && npm run i18n-compile; vue-cli-service serve --port ${VUE_PORT:-8080} --host ${VUE_HOST:-0.0.0.0}", "serve": "[ ! -d src/translations ] && npm run i18n-compile; vue-cli-service serve --port ${VUE_PORT:-8080} --host ${VUE_HOST:-0.0.0.0}",
"build": "scripts/i18n-compile.sh && vue-cli-service build", "build": "scripts/i18n-compile.sh && vue-cli-service build",
"test:unit": "vue-cli-service test:unit --reporter mocha-junit-reporter", "test:unit": "vue-cli-service test:unit --reporter mocha-junit-reporter",
"lint": "vue-cli-service lint", "lint": "eslint $(git status --porcelain --untracked-files=no | grep -E '(A|M) ' | cut -d' ' -f3 | sed s_front/__ | grep -E '.(js|vue)$')",
"i18n-compile": "scripts/i18n-compile.sh", "i18n-compile": "scripts/i18n-compile.sh",
"i18n-extract": "scripts/i18n-extract.sh", "i18n-extract": "scripts/i18n-extract.sh",
"fix-fomantic-css": "scripts/fix-fomantic-css.sh", "fix-fomantic-css": "scripts/fix-fomantic-css.sh",
@ -44,8 +44,8 @@
"vuex-router-sync": "^5.0.0" "vuex-router-sync": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/eslint-parser": "^7.13.14",
"@vue/cli-plugin-babel": "~4.2.2", "@vue/cli-plugin-babel": "~4.2.2",
"@vue/cli-plugin-eslint": "~4.2.2",
"@vue/cli-plugin-pwa": "~4.2.2", "@vue/cli-plugin-pwa": "~4.2.2",
"@vue/cli-plugin-unit-mocha": "~4.2.2", "@vue/cli-plugin-unit-mocha": "~4.2.2",
"@vue/cli-service": "~4.2.2", "@vue/cli-service": "~4.2.2",
@ -53,9 +53,13 @@
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"chai": "^4.1.2", "chai": "^4.1.2",
"easygettext": "^2.6.3", "easygettext": "^2.6.3",
"eslint": "^5.16.0", "eslint": "^7.25.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-html": "^4.0.5", "eslint-plugin-html": "^4.0.5",
"eslint-plugin-vue": "^6.1.2", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-vue": "^7.9.0",
"glob-all": "^3.1.0", "glob-all": "^3.1.0",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"mocha-junit-reporter": "^2.0.0", "mocha-junit-reporter": "^2.0.0",

View File

@ -1,90 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.0170" tests="27" failures="1">
<testsuite name="Root Suite" timestamp="2021-04-22T13:53:41" tests="0" time="0.0000" failures="0">
</testsuite>
<testsuite name="search" timestamp="2021-04-22T13:53:41" tests="3" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0030" failures="0">
<testcase name="search normalizeQuery returns correct tokens" time="0.0010" classname="normalizeQuery returns correct tokens">
</testcase>
<testcase name="search parseTokens can extract fields and values from tokens" time="0.0010" classname="parseTokens can extract fields and values from tokens">
</testcase>
<testcase name="search compileTokens returns proper query string" time="0.0010" classname="compileTokens returns proper query string">
</testcase>
</testsuite>
<testsuite name="utils" timestamp="2021-04-22T13:53:41" tests="0" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0">
</testsuite>
<testsuite name="parseAPIErrors" timestamp="2021-04-22T13:53:41" tests="4" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0010" failures="0">
<testcase name="utils parseAPIErrors handles flat structure" time="0.0010" classname="handles flat structure">
</testcase>
<testcase name="utils parseAPIErrors handles flat structure with multiple errors per field" time="0.0000" classname="handles flat structure with multiple errors per field">
</testcase>
<testcase name="utils parseAPIErrors translate field name" time="0.0000" classname="translate field name">
</testcase>
<testcase name="utils parseAPIErrors handle nested fields" time="0.0000" classname="handle nested fields">
</testcase>
</testsuite>
<testsuite name="Username" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0040" failures="0">
<testcase name="Username displays username" time="0.0040" classname="displays username">
</testcase>
</testsuite>
<testsuite name="filters" timestamp="2021-04-22T13:53:41" tests="0" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0">
</testsuite>
<testsuite name="truncate" timestamp="2021-04-22T13:53:41" tests="3" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0">
<testcase name="filters truncate leave strings as it if correct size" time="0.0000" classname="leave strings as it if correct size">
</testcase>
<testcase name="filters truncate returns shorter string with character" time="0.0000" classname="returns shorter string with character">
</testcase>
<testcase name="filters truncate custom ellipsis" time="0.0000" classname="custom ellipsis">
</testcase>
</testsuite>
<testsuite name="ago" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0020" failures="0">
<testcase name="filters ago works" time="0.0020" classname="works">
</testcase>
</testsuite>
<testsuite name="year" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0020" failures="0">
<testcase name="filters year works" time="0.0020" classname="works">
</testcase>
</testsuite>
<testsuite name="capitalize" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0">
<testcase name="filters capitalize works" time="0.0000" classname="works">
</testcase>
</testsuite>
<testsuite name="store/auth" timestamp="2021-04-22T13:53:41" tests="0" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0">
</testsuite>
<testsuite name="mutations" timestamp="2021-04-22T13:53:41" tests="7" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0020" failures="0">
<testcase name="store/auth mutations profile" time="0.0010" classname="profile">
</testcase>
<testcase name="store/auth mutations username" time="0.0000" classname="username">
</testcase>
<testcase name="store/auth mutations authenticated true" time="0.0000" classname="authenticated true">
</testcase>
<testcase name="store/auth mutations authenticated false" time="0.0010" classname="authenticated false">
</testcase>
<testcase name="store/auth mutations token null" time="0.0000" classname="token null">
</testcase>
<testcase name="store/auth mutations token real" time="0.0000" classname="token real">
</testcase>
<testcase name="store/auth mutations permissions" time="0.0000" classname="permissions">
</testcase>
</testsuite>
<testsuite name="getters" timestamp="2021-04-22T13:53:41" tests="1" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0000" failures="0">
<testcase name="store/auth getters header" time="0.0000" classname="header">
</testcase>
</testsuite>
<testsuite name="actions" timestamp="2021-04-22T13:53:41" tests="5" file="/home/georg/workspace/funkwhale/front/dist/js/main.js" time="0.0030" failures="1">
<testcase name="store/auth actions logout" time="0.0000" classname="logout">
</testcase>
<testcase name="store/auth actions check jwt null" time="0.0010" classname="check jwt null">
</testcase>
<testcase name="store/auth actions login success" time="0.0010" classname="login success">
</testcase>
<testcase name="store/auth actions login error" time="0.0010" classname="login error">
</testcase>
<testcase name="store/auth actions fetchProfile" time="0.0000" classname="fetchProfile">
</testcase>
<testcase name="store/auth actions fetchProfile" time="0.0000" classname="fetchProfile">
<failure message="expected &apos;favorites/fetch&apos; to equal &apos;ui/initSettings&apos;" type="AssertionError"><![CDATA[AssertionError: expected 'favorites/fetch' to equal 'ui/initSettings'
at dispatch (dist/js/main.js:192702:34)
at /home/georg/workspace/funkwhale/front/dist/js/main.js:184555:11]]></failure>
</testcase>
</testsuite>
</testsuites>