Skip to content

Commit 1be7dd9

Browse files
committed
Fix style issues and package errors before pushing release
1 parent 1da494e commit 1be7dd9

File tree

5 files changed

+79
-76
lines changed

5 files changed

+79
-76
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Calling out known issues can help limit users opening duplicate issues against y
2121

2222
## Release Notes
2323

24-
### Latest 0.1.0 (2017.01.16)
24+
### Latest 0.1.0 (2017.01.17)
2525

2626
- First Release
2727
- Add support for css hexa colors

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "vscode_colorize",
2+
"name": "vscode-colorize",
33
"displayName": "colorize",
44
"description": "A vscode extension to help visualize css colors in files.",
55
"version": "0.1.0",
66
"publisher": "KamiKillertO",
77
"license": "Apache-2.0",
8-
"icon": "logo.png",
8+
"icon": "assets/logo.png",
99
"engines": {
1010
"vscode": "^1.5.0"
1111
},

src/extension.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ export function activate(context: ExtensionContext) {
2828
let timeout = null;
2929
let editor = window.activeTextEditor;
3030

31-
function triggerUpdateDecorations(/*range*/) {
31+
function triggerUpdateDecorations( /*range*/ ) {
3232
if (timeout) {
3333
clearTimeout(timeout);
3434
}
3535

3636
timeout = setTimeout(updateDecorations, 500);
3737
}
3838

39-
function updateDecorations( /*editor: TextEditor, editedRange: Range*/) {
39+
function updateDecorations( /*editor: TextEditor, editedRange: Range*/ ) {
4040
if (!editor) {
4141
return;
4242
}
4343

44-
let disposed = decorations.filter(decoration => {
45-
decoration.checkDecoration(editor)
46-
return decoration.disposed;
44+
45+
let disposed = decorations.filter(decoration => {
46+
decoration.checkDecoration(editor);
47+
return decoration.disposed;
4748
});
4849

4950
let text = window.activeTextEditor.document.getText();
@@ -56,7 +57,7 @@ export function activate(context: ExtensionContext) {
5657
text = text.substr(match.index + match[1].length);
5758
let alreadyIn = decorations.find(decoration => decoration.textPosition.start.isEqual(startPos) && decoration.textPosition.end.isEqual(endPos));
5859
if (alreadyIn) {
59-
continue;
60+
continue;
6061
}
6162
let range = new Range(startPos, endPos);
6263

@@ -78,7 +79,7 @@ export function activate(context: ExtensionContext) {
7879

7980
workspace.onDidChangeTextDocument(event => {
8081
if (editor && event.document === editor.document) {
81-
triggerUpdateDecorations(/*event.contentChanges*/);
82+
triggerUpdateDecorations( /*event.contentChanges*/ );
8283
}
8384
}, null, context.subscriptions);
8485
}
@@ -87,7 +88,7 @@ export function activate(context: ExtensionContext) {
8788
function generateDecorator(color: string): TextEditorDecorationType {
8889
let textColor = null;
8990
let luminance = ColorUtil.luminance(color);
90-
if (luminance < 0.7) {
91+
if (luminance < 0.7) {
9192
textColor = '#fff';
9293
} else {
9394
textColor = '#000';
@@ -103,7 +104,7 @@ function generateDecorator(color: string): TextEditorDecorationType {
103104
}
104105

105106
// this method is called when your extension is deactivated
106-
export function deactivate() { }
107+
export function deactivate() {}
107108

108109

109110
class ColorDecoration {
@@ -120,7 +121,7 @@ class ColorDecoration {
120121
this._match = match;
121122
}
122123
public checkDecoration(editor: TextEditor): void {
123-
let character_after = editor.document.lineAt(this.textPosition.start.line).text.substring(this.textPosition.end.character, this.textPosition.end.character + 1)
124+
let character_after = editor.document.lineAt(this.textPosition.start.line).text.substring(this.textPosition.end.character, this.textPosition.end.character + 1);
124125
let text = editor.document.lineAt(this.textPosition.start.line).text.substring(this.textPosition.start.character, this.textPosition.end.character + 1);
125126
if (!this._matcher.test(text) || character_after === "") {
126127
this._decoration.dispose();
@@ -139,7 +140,9 @@ class ColorDecoration {
139140
this._decoration.dispose();
140141
let decoration = generateDecorator(this._match);
141142
this._decoration = decoration;
142-
editor.setDecorations(this._decoration, [{ range: this.textPosition }]);
143+
editor.setDecorations(this._decoration, [{
144+
range: this.textPosition
145+
}]);
143146
}
144147
public dispose(): void {
145148
this._decoration.dispose();

test/extension.test.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,61 @@ import { assert } from 'chai';
22

33
// You can import and use all API from the 'vscode' module
44
// as well as import your extension to test it
5-
import { HEXA_COLOR } from '../src/color-regex';
5+
import { HEXA_COLOR } from '../src/color-regex';
66
import ColorUtil from '../src/color-util';
77

88
// Defines a Mocha test suite to group tests of similar kind together
9-
describe("Test CSS hexa shorthand color Regex", () => {
10-
it('Should match color with only integer', function() {
11-
assert.ok('#000'.match(HEXA_COLOR));
12-
});
13-
it('Should match color with letters and integers', function() {
14-
assert.ok('#f0a'.match(HEXA_COLOR));
15-
});
16-
it('Should match color with only letters', function() {
17-
assert.ok('#fff'.match(HEXA_COLOR));
18-
});
19-
it('Regex should not care about the case', function() {
20-
assert.ok('#Abc'.match(HEXA_COLOR));
21-
});
22-
it('Should match with different characters at the end', function() {
23-
assert.ok('#Abc'.match(HEXA_COLOR));
24-
assert.ok('#Abc '.match(HEXA_COLOR));
25-
assert.ok('#Abc,'.match(HEXA_COLOR));
26-
assert.ok('#Abc;'.match(HEXA_COLOR));
27-
assert.ok('#Abc\n'.match(HEXA_COLOR));
28-
});
29-
it('Should not match', function() {
30-
assert.notOk('#AbG'.match(HEXA_COLOR));
31-
assert.notOk('#AbcG'.match(HEXA_COLOR));
32-
assert.notOk('#Ab'.match(HEXA_COLOR));
33-
});
34-
});
35-
describe("Test CSS hexa color Regex", () => {
36-
it('Should match color with only integer', function() {
37-
assert.ok('#000000'.match(HEXA_COLOR));
38-
});
39-
it('Should match color with letters and integers', function() {
40-
assert.ok('#f0f0f0'.match(HEXA_COLOR));
41-
});
42-
it('Should match color with only letters', function() {
43-
assert.ok('#ffffff'.match(HEXA_COLOR));
44-
});
45-
it('Regex should not care about the case', function() {
46-
assert.ok('#Abc012'.match(HEXA_COLOR));
47-
});
48-
it('Should match with different characters at the end', function() {
49-
assert.ok('#ffffff '.match(HEXA_COLOR));
50-
assert.ok('#ffffff,'.match(HEXA_COLOR));
51-
assert.ok('#ffffff;'.match(HEXA_COLOR));
52-
assert.ok('#ffffff\n'.match(HEXA_COLOR));
53-
});
54-
it('Should not match', function() {
55-
assert.notOk('#fffffg'.match(HEXA_COLOR));
56-
assert.notOk('#ffffffg'.match(HEXA_COLOR));
57-
assert.notOk('#fffff'.match(HEXA_COLOR));
58-
});
59-
});
9+
describe("Test CSS hexa shorthand color Regex", () => {
10+
it('Should match color with only integer', function () {
11+
assert.ok('#000'.match(HEXA_COLOR));
12+
});
13+
it('Should match color with letters and integers', function () {
14+
assert.ok('#f0a'.match(HEXA_COLOR));
15+
});
16+
it('Should match color with only letters', function () {
17+
assert.ok('#fff'.match(HEXA_COLOR));
18+
});
19+
it('Regex should not care about the case', function () {
20+
assert.ok('#Abc'.match(HEXA_COLOR));
21+
});
22+
it('Should match with different characters at the end', function () {
23+
assert.ok('#Abc'.match(HEXA_COLOR));
24+
assert.ok('#Abc '.match(HEXA_COLOR));
25+
assert.ok('#Abc,'.match(HEXA_COLOR));
26+
assert.ok('#Abc;'.match(HEXA_COLOR));
27+
assert.ok('#Abc\n'.match(HEXA_COLOR));
28+
});
29+
it('Should not match', function () {
30+
assert.notOk('#AbG'.match(HEXA_COLOR));
31+
assert.notOk('#AbcG'.match(HEXA_COLOR));
32+
assert.notOk('#Ab'.match(HEXA_COLOR));
33+
});
34+
});
35+
describe("Test CSS hexa color Regex", () => {
36+
it('Should match color with only integer', function () {
37+
assert.ok('#000000'.match(HEXA_COLOR));
38+
});
39+
it('Should match color with letters and integers', function () {
40+
assert.ok('#f0f0f0'.match(HEXA_COLOR));
41+
});
42+
it('Should match color with only letters', function () {
43+
assert.ok('#ffffff'.match(HEXA_COLOR));
44+
});
45+
it('Regex should not care about the case', function () {
46+
assert.ok('#Abc012'.match(HEXA_COLOR));
47+
});
48+
it('Should match with different characters at the end', function () {
49+
assert.ok('#ffffff '.match(HEXA_COLOR));
50+
assert.ok('#ffffff,'.match(HEXA_COLOR));
51+
assert.ok('#ffffff;'.match(HEXA_COLOR));
52+
assert.ok('#ffffff\n'.match(HEXA_COLOR));
53+
});
54+
it('Should not match', function () {
55+
assert.notOk('#fffffg'.match(HEXA_COLOR));
56+
assert.notOk('#ffffffg'.match(HEXA_COLOR));
57+
assert.notOk('#fffff'.match(HEXA_COLOR));
58+
});
59+
});
6060
describe("Test CSS hexa shorthand color Regex", () => {
6161
it('Should match color with only integer', function () {
6262
assert.ok('#000'.match(HEXA_COLOR));
@@ -120,7 +120,7 @@ describe('Test utility fonction', () => {
120120
assert.equal(ColorUtil.luminance('#000'), 0, 'Should be "0" for #000');
121121
assert.equal(ColorUtil.luminance('#000000'), 0, 'Should be "0" for #000000');
122122

123-
assert.equal(ColorUtil.luminance('#ccc').toFixed(1), 0.6 , 'Should be around "0.6" for #ccc');
124-
123+
assert.equal(ColorUtil.luminance('#ccc').toFixed(1), 0.6, 'Should be around "0.6" for #ccc');
124+
125125
});
126126
});

test/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// host can call to run the tests. The test runner is expected to use console.log
1010
// to report the results back to the caller. When the tests are finished, return
1111
// a possible error to the callback or null if none.
12-
13-
var testRunner = require('vscode/lib/testrunner');
14-
12+
13+
let testRunner = require('vscode/lib/testrunner');
14+
1515
// You can directly control Mocha options by uncommenting the following lines
1616
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17-
testRunner.configure({
18-
// ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
19-
useColors: true // colored output from test results
20-
});
21-
17+
testRunner.configure({
18+
// ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
19+
useColors: true // colored output from test results
20+
});
21+
2222
module.exports = testRunner;

0 commit comments

Comments
 (0)