I was following the Nextcloud tutorial “Developing a dashboard widget with Vue.js” to create a dashboard widget using Vue.
The dependencies I am using are:
{
"@nextcloud/vue": "^9.8.2",
"vue": "^3.5.35",
"vue-material-design-icons": "^5.3.1"
}
When I ran:
npm run dev
the build failed with ESLint errors in the two source files:
-
src/dashboardVue.js -
src/views/GifWidget.vue
The errors were:
Expected indentation of 1 tab but found 4 spaces
Expected indentation of 2 tabs but found 8 spaces
Expected indentation of 3 tabs but found 12 spaces
and:
Newline required at end of file but not found
Steps to reproduce
-
Follow the Nextcloud tutorial “Developing a dashboard widget with Vue.js”.
-
Use the dependencies:
{
"@nextcloud/vue": "^9.8.2",
"vue": "^3.5.35",
"vue-material-design-icons": "^5.3.1"
}
-
Copy the source code provided in the tutorial for:
-
dashboardVue.js -
GifWidget.vue
-
-
Run:
npm run dev
- The Vite build fails because ESLint expects tab indentation and a newline at the end of the files.
Error
For dashboardVue.js:
5:1 error Expected indentation of 1 tab but found 4 spaces indent
6:1 error Expected indentation of 2 tabs but found 8 spaces indent
7:1 error Expected indentation of 3 tabs but found 12 spaces indent
8:1 error Expected indentation of 2 tabs but found 8 spaces indent
9:1 error Expected indentation of 2 tabs but found 8 spaces indent
10:1 error Expected indentation of 2 tabs but found 8 spaces indent
11:1 error Expected indentation of 1 tab but found 4 spaces indent
12:3 error Newline required at end of file but not found eol-last
For GifWidget.vue:
82:9 error Newline required at end of file but not found eol-last
Root cause
The source code provided in the tutorial does not appear to follow the current ESLint formatting rules used by the project.
In particular:
-
The indentation in
dashboardVue.jsuses spaces instead of tabs. -
dashboardVue.jsis missing the required newline at the end of the file. -
GifWidget.vueis also missing the required newline at the end of the file.
You can verify the actual characters from WSL:
cat -A src/dashboardVue.js
You should see ^I for tabs:
^IOCA.Dashboard.register(...)
^I^Iconst app = createApp(...)
^I^I^Ititle: widget.title,
If you see like this, then they’re still spaces.:
OCA.Dashboard
const app
Solution
I manually changed the indentation in dashboardVue.js from spaces to tabs and added the missing newline at the end of the file.
I also added the missing newline at the end of GifWidget.vue.
After making these formatting changes, I ran:
npm run dev
and the project built successfully.
Suggestion
It would be helpful to update the source code in the tutorial so that the provided files conform to the ESLint configuration used by the current Nextcloud development environment.
Specifically, the code examples should:
-
Use tabs for indentation where required by the ESLint configuration.
-
Include a newline at the end of the source files.
This would prevent new users following the tutorial from encountering ESLint build errors immediately after copying the provided source code.