Add tslint
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"prestart": "tsc demo/generate.ts",
|
"prestart": "tsc demo/generate.ts",
|
||||||
"start": "node demo/generate.js",
|
"start": "node demo/generate.js",
|
||||||
"prepublish": "npm run build"
|
"prepublish": "npm run build",
|
||||||
|
"lint": "tslint src/*.ts"
|
||||||
},
|
},
|
||||||
"author": "Tyriar",
|
"author": "Tyriar",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -22,6 +23,8 @@
|
|||||||
"typings": "dist/index",
|
"typings": "dist/index",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^6.0.41",
|
"@types/node": "^6.0.41",
|
||||||
|
"tslint": "^5.9.1",
|
||||||
|
"tslint-consistent-codestyle": "^1.13.0",
|
||||||
"typescript": "^2.8.3"
|
"typescript": "^2.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IColorSet, IBaseColorSet } from "./interfaces";
|
import { IColorSet, IBaseColorSet } from './interfaces';
|
||||||
|
|
||||||
export function lighten(color: string, amount: number): string {
|
export function lighten(color: string, amount: number): string {
|
||||||
const MAX = 255;
|
const MAX = 255;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { IColorSet } from './interfaces'
|
import { IColorSet } from './interfaces';
|
||||||
import { VscodeThemeGenerator } from './vscodeThemeGenerator'
|
import { VscodeThemeGenerator } from './vscodeThemeGenerator';
|
||||||
|
|
||||||
export function generateTheme(themeName: string, colorSet: IColorSet, outputFile: string) {
|
export function generateTheme(themeName: string, colorSet: IColorSet, outputFile: string): void {
|
||||||
const themeJson = new VscodeThemeGenerator().generateTheme(themeName, colorSet);
|
const themeJson = new VscodeThemeGenerator().generateTheme(themeName, colorSet);
|
||||||
fs.writeFileSync(outputFile, themeJson);
|
fs.writeFileSync(outputFile, themeJson);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface IBaseColorSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IColorSet {
|
export interface IColorSet {
|
||||||
base: IBaseColorSet,
|
base: IBaseColorSet;
|
||||||
syntax?: {
|
syntax?: {
|
||||||
boolean?: string;
|
boolean?: string;
|
||||||
function?: string;
|
function?: string;
|
||||||
@@ -33,7 +33,7 @@ export interface IColorSet {
|
|||||||
cssId?: string;
|
cssId?: string;
|
||||||
cssTag?: string;
|
cssTag?: string;
|
||||||
markdownQuote?: string;
|
markdownQuote?: string;
|
||||||
}
|
};
|
||||||
ui?: {
|
ui?: {
|
||||||
/** The color of the editor cursor/caret */
|
/** The color of the editor cursor/caret */
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
@@ -56,7 +56,7 @@ export interface IColorSet {
|
|||||||
wordHighlight?: string;
|
wordHighlight?: string;
|
||||||
wordHighlightStrong?: string;
|
wordHighlightStrong?: string;
|
||||||
activeLinkForeground?: string;
|
activeLinkForeground?: string;
|
||||||
},
|
};
|
||||||
terminal?: {
|
terminal?: {
|
||||||
black?: string;
|
black?: string;
|
||||||
red?: string;
|
red?: string;
|
||||||
@@ -74,6 +74,6 @@ export interface IColorSet {
|
|||||||
brightMagenta?: string;
|
brightMagenta?: string;
|
||||||
brightCyan?: string;
|
brightCyan?: string;
|
||||||
brightWhite?: string;
|
brightWhite?: string;
|
||||||
},
|
};
|
||||||
overrides?: { [key: string]: string }
|
overrides?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IColorSet, IThemeGenerator, IBaseColorSet } from './interfaces'
|
import { IColorSet, IThemeGenerator, IBaseColorSet } from './interfaces';
|
||||||
import { darken, lighten } from './color';
|
import { darken, lighten } from './color';
|
||||||
|
|
||||||
export interface IVscodeJsonThemeSetting {
|
export interface IVscodeJsonThemeSetting {
|
||||||
@@ -18,7 +18,7 @@ export interface IRuleGenerator {
|
|||||||
generate: ColorGenerator;
|
generate: ColorGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FontStyle {
|
const enum FontStyle {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
ITALIC = 1 << 0,
|
ITALIC = 1 << 0,
|
||||||
BOLD = 1 << 1,
|
BOLD = 1 << 1,
|
||||||
@@ -32,7 +32,7 @@ function getGlobalSettingGenerator(name: string): ColorGenerator {
|
|||||||
}
|
}
|
||||||
const result: any = {};
|
const result: any = {};
|
||||||
result[name] = color;
|
result[name] = color;
|
||||||
return result
|
return result;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ function getSimpleColorGenerator(name: string, scope: string, fontStyle: number
|
|||||||
colorRule.settings.fontStyle = fontStyles.join(' ');
|
colorRule.settings.fontStyle = fontStyles.join(' ');
|
||||||
}
|
}
|
||||||
return colorRule;
|
return colorRule;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const globalRules: IRuleGenerator[] = [
|
export const globalRules: IRuleGenerator[] = [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IColorSet, IThemeGenerator, IBaseColorSet } from './interfaces'
|
import { IColorSet, IThemeGenerator, IBaseColorSet } from './interfaces';
|
||||||
import { darken, lighten, generateFallbackColorSet, addAlpha } from './color';
|
import { darken, lighten, generateFallbackColorSet, addAlpha } from './color';
|
||||||
import { tokenRules, globalRules, IVscodeJsonThemeSetting } from './rules';
|
import { tokenRules, globalRules, IVscodeJsonThemeSetting } from './rules';
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ export class VscodeThemeGenerator implements IThemeGenerator {
|
|||||||
return JSON.stringify(theme, null, 2);
|
return JSON.stringify(theme, null, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _applyWorkbenchColors(theme: IVscodeJsonTheme, colorSet: IColorSet) {
|
private _applyWorkbenchColors(theme: IVscodeJsonTheme, colorSet: IColorSet): void {
|
||||||
const background1 = darken(colorSet.base.background, 0.2);
|
const background1 = darken(colorSet.base.background, 0.2);
|
||||||
const background2 = colorSet.base.background;
|
const background2 = colorSet.base.background;
|
||||||
const background3 = lighten(colorSet.base.background, 0.2);
|
const background3 = lighten(colorSet.base.background, 0.2);
|
||||||
|
|||||||
105
tslint.json
Normal file
105
tslint.json
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
{
|
||||||
|
"rulesDirectory": [
|
||||||
|
"tslint-consistent-codestyle"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"array-type": [
|
||||||
|
true,
|
||||||
|
"array"
|
||||||
|
],
|
||||||
|
"class-name": true,
|
||||||
|
"comment-format": [
|
||||||
|
true,
|
||||||
|
"check-space"
|
||||||
|
],
|
||||||
|
"curly": [
|
||||||
|
true,
|
||||||
|
"ignore-same-line"
|
||||||
|
],
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"interface-name": [
|
||||||
|
true,
|
||||||
|
"always-prefix"
|
||||||
|
],
|
||||||
|
"interface-over-type-literal": true,
|
||||||
|
"typedef": [
|
||||||
|
true,
|
||||||
|
"call-signature",
|
||||||
|
"parameter"
|
||||||
|
],
|
||||||
|
"eofline": true,
|
||||||
|
"no-duplicate-imports": true,
|
||||||
|
"no-eval": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"one-variable-per-declaration": true,
|
||||||
|
"no-unsafe-finally": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semicolon": [
|
||||||
|
true,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"trailing-comma": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"multiline": {
|
||||||
|
"objects": "never",
|
||||||
|
"arrays": "never",
|
||||||
|
"functions": "never",
|
||||||
|
"typeLiterals": "ignore"
|
||||||
|
},
|
||||||
|
"esSpecCompliant": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"triple-equals": [
|
||||||
|
true,
|
||||||
|
"allow-null-check"
|
||||||
|
],
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"ban-keywords",
|
||||||
|
"check-format",
|
||||||
|
"allow-leading-underscore"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-decl",
|
||||||
|
"check-module",
|
||||||
|
"check-operator",
|
||||||
|
"check-rest-spread",
|
||||||
|
"check-separator",
|
||||||
|
"check-type",
|
||||||
|
"check-type-operator",
|
||||||
|
"check-preblock"
|
||||||
|
],
|
||||||
|
|
||||||
|
"naming-convention": [
|
||||||
|
true,
|
||||||
|
{"type": "property", "modifiers": ["public", "static", "const"], "format": "UPPER_CASE"}
|
||||||
|
],
|
||||||
|
"no-else-after-return": {
|
||||||
|
"options": "allow-else-if"
|
||||||
|
},
|
||||||
|
"prefer-const-enum": [
|
||||||
|
true
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user