Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/samples/indent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four (correct)": 4,
"five": 5,
"tab": "t",
"parent (correct)": {
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four (correct)": 4,
"five": 5
}
}
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const errorSignature = err =>

const getErrorCode = _.pipe(_.get('ruleId'), _.split('/'), _.last);

let jsPrefix = '/* eslint-disable *//* eslint-enable indent */(';
const processors = {
'.json': {
preprocess: function(text, fileName) {
Expand All @@ -112,7 +113,7 @@ const processors = {
const parsed = jsonServiceHandle.parseJSONDocument(textDocument);
fileLintResults[fileName] = getDiagnostics(parsed);
fileComments[fileName] = parsed.comments;
return ['']; // sorry nothing ;)
return [jsPrefix + (text || '{}') + ')'];
},
postprocess: function(messages, fileName) {
const textDocument = fileDocuments[fileName];
Expand All @@ -138,6 +139,12 @@ const processors = {
start: {line: error.line - 1, character: error.column},
end: {line: error.endLine - 1, character: error.endColumn}
});
if (error.fix) {
error.fix.range = [
error.fix.range[0] - jsPrefix.length,
error.fix.range[1] - jsPrefix.length
];
}
return _.assign(error, {
source,
column: error.column + 1,
Expand All @@ -146,7 +153,8 @@ const processors = {
}),
_.values
)(messages);
}
},
supportsAutofix: true
}
};

Expand Down
3 changes: 2 additions & 1 deletion test/custom.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"rules": {
"self/*": "warn",
"self/duplicate-key": "error",
"self/trailing-comma": "error"
"self/trailing-comma": "error",
"indent": ["error", 4]
},
"overrides": [
{
Expand Down
3 changes: 3 additions & 0 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ describe('Integrations tests', function() {
warnings: ['*']
});
});
it('indentation', function() {
validateFile('indent', {errorCount: 11, warningCount: 0});
});
});

describe('Integrations tests with config', function() {
Expand Down