Skip to content

Commit

Permalink
Use tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Oct 26, 2016
2 parents 691c398 + b12ccd2 commit 0dbafe6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 76 deletions.
11 changes: 7 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
root = true

[*]
indent_style = space
indent_size = 2
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
[{.travis.yml,npm-shrinkwrap.json,package.json}]
indent_style = space
indent_size = 2
24 changes: 13 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// A launch configuration that launches the extension inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"stopOnEntry": false
}
]
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false
}
]
}
96 changes: 48 additions & 48 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,65 @@ const vscode = require('vscode');
const lebab = require('lebab');

function makeDiagnostic(problem, stringLength) {
return {
severity: vscode.DiagnosticSeverity.Warning,
range: {
start: {
line: problem.line - 1,
character: 0
},
end: {
line: problem.line - 1,
character: stringLength
}
},
source: 'lebab',
message: `${problem.msg} [${problem.type}]`
};
return {
severity: vscode.DiagnosticSeverity.Warning,
range: {
start: {
line: problem.line - 1,
character: 0
},
end: {
line: problem.line - 1,
character: stringLength
}
},
source: 'lebab',
message: `${problem.msg} [${problem.type}]`
};
}

function activate(context) {
const convert = vscode.commands.registerTextEditorCommand('lebab.convert', (textEditor) => {
const options = vscode.workspace.getConfiguration('lebab');
const convert = vscode.commands.registerTextEditorCommand('lebab.convert', (textEditor) => {
const options = vscode.workspace.getConfiguration('lebab');

const text = textEditor.document.getText();
let result = {
code: text,
warnings: []
};
const text = textEditor.document.getText();
let result = {
code: text,
warnings: []
};

try {
result = lebab.transform(text, options.transforms);
} catch (err) {
console.error(err);
}
try {
result = lebab.transform(text, options.transforms);
} catch (err) {
console.error(err);
}

if (!options.skipWarnings) {
const collection = vscode.languages.createDiagnosticCollection();
const diagnostics = result.warnings.map((problem) => {
const line = textEditor.document.lineAt(problem.line - 1);
return makeDiagnostic(problem, line.text.length);
});
if (!options.skipWarnings) {
const collection = vscode.languages.createDiagnosticCollection();
const diagnostics = result.warnings.map((problem) => {
const line = textEditor.document.lineAt(problem.line - 1);
return makeDiagnostic(problem, line.text.length);
});

collection.set(textEditor.document.uri, diagnostics);
collection.set(textEditor.document.uri, diagnostics);

vscode.window.onDidChangeActiveTextEditor(() => {
collection.delete(textEditor.document.uri);
});
}
vscode.window.onDidChangeActiveTextEditor(() => {
collection.delete(textEditor.document.uri);
});
}

textEditor.edit((editBuilder) => {
const document = textEditor.document;
const lastLine = document.lineAt(document.lineCount - 1);
const start = new vscode.Position(0, 0);
const end = new vscode.Position(document.lineCount - 1, lastLine.text.length);
const range = new vscode.Range(start, end);
textEditor.edit((editBuilder) => {
const document = textEditor.document;
const lastLine = document.lineAt(document.lineCount - 1);
const start = new vscode.Position(0, 0);
const end = new vscode.Position(document.lineCount - 1, lastLine.text.length);
const range = new vscode.Range(start, end);

editBuilder.replace(range, result.code);
});
});
editBuilder.replace(range, result.code);
});
});

context.subscriptions.push(convert);
context.subscriptions.push(convert);
}

exports.activate = activate;
24 changes: 12 additions & 12 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"test": "xo"
},
"xo": {
"space": true,
"rules": {
"no-var": 2,
"prefer-const": [2, { "destructuring": "all" }],
Expand Down

0 comments on commit 0dbafe6

Please sign in to comment.