I get this annoying 'error' message in Vue.js
app.
error: Mixed spaces and tabs (no-mixed-spaces-and-tabs) at src/components/Landing.vue:388:2:
I'm wondering how can I suppress it?
I get this annoying 'error' message in Vue.js
app.
error: Mixed spaces and tabs (no-mixed-spaces-and-tabs) at src/components/Landing.vue:388:2:
I'm wondering how can I suppress it?
That's an ESLint error (no-mixed-spaces-and-tabs
), intended to warn against using both space and tab for indenting code. Consistency of spaces/tabs is a code convention, which is important when sharing a codebase within a team (1) (2). If you're swinging it alone (and have no plans otherwise), feel free to disable/enable any rules you want.
You can configure ESLint to ignore that error in your entire project. The configuration is usually stored in .eslintrc.js
in a Vue CLI generated project. Inside that file, edit the rules
object to contain:
// .eslintrc.js
module.exports = {
"rules": {
"no-mixed-spaces-and-tabs": 0, // disable rule
}
}
To ignore that error for a single line only, use an inline comment (eslint-disable-line no-mixed-spaces-and-tabs
or eslint-disable-next-line no-mixed-spaces-and-tabs
) on that line:
⋅⋅const x = 1
⇥⋅⋅const y = 2 // eslint-disable-line no-mixed-spaces-and-tabs
// eslint-disable-next-line no-mixed-spaces-and-tabs
⇥⋅⋅const z = 3
To ignore that error for multiple lines of code, surround the code with eslint-disable no-mixed-spaces-and-tabs
and eslint-enable no-mixed-spaces-and-tabs
multi-line comments:
⋅⋅const x = 1
/* eslint-disable no-mixed-spaces-and-tabs */
⇥⋅⋅const y = 2 //
⇥⋅⋅const z = 3 //
/* eslint-enable no-mixed-spaces-and-tabs */
⇥⋅⋅const q = 4 // ❌ error: mixed spaces and tabs!
Go to view option
then go to indentation
and you will find indent using space
. Your problem should be fixed. If it is not fixed then go to convert indention to spaces
.
By fixing those code style issues.
That's an ESLint rule violation. It has no impact on whether your code actually runs, but it warns you that your source code is not ideally formatted.
It means that in your code indentation (which are invisible characters) you are using a mix of tabs and spaces.
It should be either one or the other. So make sure you always use either tabs or spaces but never both.
Most IDE's have options to convert tab to spaces or vice versa, to convert existing code so it complies with this rule.
Otherwise @tony19's answer has you covered.