ClassDeclaration/ClassExpression option for the indent rule
See original GitHub issueTell us about your environment
- ESLint Version: v3.17.1 (using the
indent-rewrite
branch) - Node Version: v7.7.2
- npm Version: v4.1.2
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 8
},
rules: {
indent: [2, 2, {
SwitchCase: 2,
VariableDeclarator: 2,
outerIIFEBody: 2,
MemberExpression: 2,
FunctionDeclaration: {
parameters: 2,
body: 2
},
FunctionExpression: {
parameters: 2,
body: 2
},
CallExpression: {
arguments: 2
},
ArrayExpression: 2,
ObjectExpression: 2
}]
}
};
What did you do? Please include the actual source code causing the issue.
class a {
m() {
"hmm";
}
}
let b = class {
m() {
"hmm";
}
};
What did you expect to happen?
There should be an option to set the indentation for ClassDeclaration
and ClassExpression
.
What actually happened? Please include the actual, raw output from ESLint.
c:\nodejs\test\test.js
2:5 error Expected indentation of 2 spaces but found 4 indent
3:9 error Expected indentation of 6 spaces but found 8 indent
4:5 error Expected indentation of 2 spaces but found 4 indent
7:5 error Expected indentation of 2 spaces but found 4 indent
8:9 error Expected indentation of 6 spaces but found 8 indent
9:5 error Expected indentation of 2 spaces but found 4 indent
✖ 6 problems (6 errors, 0 warnings)
$ eslint test.js --fix
Lints to:
class a {
m() {
"hmm";
}
}
let b = class {
m() {
"hmm";
}
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
class expression - JavaScript - MDN Web Docs - Mozilla
The class keyword can be used to define a class inside an expression. Similar to function expressions, class expressions can be named or...
Read more >Rules - JavaScript Standard Style
Use 2 spaces for indentation. eslint: indent · Use single quotes for strings except to avoid escaping. eslint: quotes · No unused variables....
Read more >Optional Braces - Scala 3 - EPFL
Scala 3 enforces some rules on indentation and allows some occurrences of braces {. ... of a class, trait, or object that are...
Read more >indent - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >indent | typescript-eslint
indent. danger. We strongly recommend you do not use this rule or any other formatting linter rules. Use ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It would be better to depend on
lodash
,ast-utils
, andfunctional-red-black-tree
directly in your plugin rather than loading ESLint’s versions of the modules at runtime. That way, your plugin won’t break if ESLint modifies its dependencies or helper functions in a future release.@mqklin That error is caused by this line:
const lodash = require('../../eslint/node_modules/lodash');
To explain this line: I’m assuming that ESLint and my plugin both are installed globally. It is in my case and it just works fine. If you need it to work locally, just fill an issue and I’m going to fix it.