New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vue/script-indent: ignoring nested arrays/objects causes incorrect formatting for object (TypeScript) #834
Comments
Workaround: Insert an empty function as the first in the class, which somehow allows the linter to format the subsequent lines correctly (in addition to ignoring nested arrays/objects): @Component
export default class HelloWorld extends Vue {
_unused() {} 👈
@Prop() private msg!: string;
foo() {
const x = {
a: [],
b: 1,
c: {},
d: 2
}
return x;
}
} |
Related: #833 and eslint/eslint#11445 |
Closing in favor of #833. |
Ok. Given your comment in #833, it makes sense that this is probably a duplicate of #833. I just wanted to point out that this issue is slightly different, and perhaps the subtle differences are significant. I noticed a few lines that are unexpectedly not indented ( import { Component, Prop, Vue } from 'vue-property-decorator' // Indented with base indent
@Component //❌1: Why is this not indented? Expected base indent
export default class HelloWorld extends Vue { // Indented with base indent
@Prop() private msg!: string; //❌2: Why is this not indented? Expected base+1 indent
foo () { // Not indented because it's aligned with first property (`msg`) of current block ('HelloWorld')
const x = { //❌3: Why is this not indented? Expected base indent
a: [], // Not indented because it's ignored
b: 1, // Not indented because it's aligned with first property (`a`) of current block (`x`)
c: {}, // Not indented because it's ignored
d: 2 // Not indented because it's aligned with first property (`a`) of current block (`x`)
} // Not indented because it's aligned with declaration of current block (`x`)
return x //❌4: Why is this not indented? Expected base indent
} // Not indented because it's aligned with declaration of current block (`foo`)
} // Indented with base indent |
Tell us about your environment
Please show your full configuration:
What did you do?
vue-cli
(pick ESLint as linter, separate config files)..eslintrc.js
.src/components/HelloWorld.vue
, add method that contains variable of object containing nested arrays/objects and literals.yarn lint
.See reproduction repo
src/components/HelloWorld.vue
:What did you expect to happen?
What actually happened?
The text was updated successfully, but these errors were encountered: