Skip to content

Commit d963c04

Browse files
committed
Add eslint interview questions and answers
1 parent 4f8aec7 commit d963c04

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ List of 300 VueJS Interview Questions
132132
|123| [How to create functional components using vue loader?](#how-to-create-functional-components-using-vue-loader)|
133133
|124| [How do you access global properties of functional components?](#how-do-you-access-global-properties-of-functional-components)|
134134
|125| [How do you perform testing in vuejs?](#how-do-you-perform-testing-in-vuejs)|
135+
|126| [How do you apply linting for css?](#how-do-you-apply-linting-for-css)|
136+
|127| [How do you use eslint plugin?](#how-do-you-use-eslint-plugin)|
137+
|128| [What is the purpose of eslint loader?](#what-is-the-purpose-of-eslint-loader)|
135138

136139
1. ### What is VueJS?
137140
**Vue.js** is an open-source, progressive Javascript framework for building user interfaces that aim to be incrementally adoptable. The core library of VueJS is focused on the `view layer` only, and is easy to pick up and integrate with other libraries or existing projects.
@@ -2314,4 +2317,58 @@ List of 300 VueJS Interview Questions
23142317
125. ### How do you perform testing in vuejs?
23152318
You can perform testing in two ways,
23162319
1. ** Using vue-cli:** It offers pre-configured unit testing and e2e testing setups
2317-
2. ** Manual setup:** You can manually setting up unit tests for *.vue files using either mocha-webpack or jest
2320+
2. ** Manual setup:** You can manually setting up unit tests for *.vue files using either mocha-webpack or jest
2321+
126. ### How do you apply linting for css?
2322+
The stylelint linter supports linting style parts of Vue single file components. You can run linter on particular vue file as below
2323+
```javascript
2324+
stylelint MyComponent.vue
2325+
```
2326+
Other option is configuring stylelint-webpack-plugin in webpack. It can be configured as a dev dependency.
2327+
```javascript
2328+
// webpack.config.js
2329+
const StyleLintPlugin = require('stylelint-webpack-plugin');
2330+
module.exports = {
2331+
// ... other options
2332+
plugins: [
2333+
new StyleLintPlugin({
2334+
files: ['**/*.{vue,htm,html,css,sss,less,scss,sass}'],
2335+
})
2336+
]
2337+
}
2338+
```
2339+
127. ### How do you use eslint plugin?
2340+
The official `eslint-plugin-vue` supports linting both the template and script parts of Vue single file components. You can configure plugin in your ESLint config,
2341+
```javascript
2342+
// .eslintrc.js
2343+
module.exports = {
2344+
extends: [
2345+
"plugin:vue/essential"
2346+
]
2347+
}
2348+
```
2349+
You can run linter on particular component as below,
2350+
```javascript
2351+
eslint --ext js,vue MyComponent.vue
2352+
```
2353+
128. ### What is the purpose of eslint loader?
2354+
You can use `eslint-loader` for *.vue files in order to automatically linted on save during development. It can be installed as npm module,
2355+
```javascript
2356+
npm install -D eslint eslint-loader
2357+
```
2358+
After that you need to add it as pre-loader,
2359+
```javascript
2360+
// webpack.config.js
2361+
module.exports = {
2362+
// ... other options
2363+
module: {
2364+
rules: [
2365+
{
2366+
enforce: 'pre',
2367+
test: /\.(js|vue)$/,
2368+
loader: 'eslint-loader',
2369+
exclude: /node_modules/
2370+
}
2371+
]
2372+
}
2373+
}
2374+
```

0 commit comments

Comments
 (0)