vuejs-templates / webpack

A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.
MIT License
9.7k stars 4.38k forks source link

Linting external JavaScript files #1308

Open smares opened 6 years ago

smares commented 6 years ago

I have a quick question: Noticing that my external JavaScript files are not processed by ESLint, I stumbled upon https://github.com/vuejs-templates/webpack/issues/716 that is now closed, but has the valuable last comment to add preLoaders: { js: 'eslint-loader' } to vue-loader.conf.js which fixed my problem. A quick look at the file on GitHub shows that the current vue-loader.conf.js is still missing that line. I am using a slightly older version of the template in my project, so I am now wondering why preLoaders: { js: 'eslint-loader' } still did not make it into the current template - is it not needed anymore because of other loaders being used?

constgen commented 3 years ago

You need to explicitly set a tip for ESlint Vue Plugin that the exported object is a component declaration

componenst-javascript.js

// @vue/component
export default {
  ...
}

But this will not bound the template with JavaScript when you

<script src="./componenst-javascript.js" />

So you will still have such errors like

The "Footer" component has been used but not registered (vue/no-unregistered-components)

Which is an issue