Skip to content

Commit

Permalink
Add a bunch of common-sense TSLint checks (and a few automatic fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebegg committed Apr 21, 2017
1 parent dfdbb80 commit a5cb768
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function run(deps = {
deps.monaco.languages.typescript.typescriptDefaults.setCompilerOptions(
compilerOptionsForViewType(viewType, strictLevel));

let oldModel = models.script.model;
const oldModel = models.script.model;
switch (strictLevel) {
case StrictLevel.STRICT:
case StrictLevel.LOOSE:
Expand Down Expand Up @@ -185,12 +185,12 @@ export function run(deps = {
function switchTab(tab: typeof currentTab, tabElement: HTMLElement) {
models[currentTab].state = deps.editor.saveViewState();
currentTab = tab;
for (let elem of Array.from(
for (const elem of Array.from(
deps.document.querySelectorAll('#tabbar > li'))) {
elem.classList.remove('current');
}
tabElement.classList.add('current');
let {model, state} = models[currentTab];
const {model, state} = models[currentTab];
deps.editor.setModel(model);
deps.editor.restoreViewState(state);
deps.editor.focus();
Expand Down Expand Up @@ -249,7 +249,7 @@ export function run(deps = {

function decodeUrl() {
const starterTemplate = deps.localStorage.getItem('starter-template');
let {
const {
viewType: newViewType,
strictLevel: newStrictLevel, scriptSource, cssSource, htmlSource
} =
Expand Down Expand Up @@ -380,7 +380,7 @@ export function run(deps = {

switchTab('script', deps.getById('ts-tab')!);

let theme = deps.localStorage.getItem('monaco-theme');
const theme = deps.localStorage.getItem('monaco-theme');
if (theme) {
onChangeColorScheme(theme);
(deps.getById('theme-select') as HTMLSelectElement).value = theme;
Expand Down
4 changes: 2 additions & 2 deletions src/main_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('main', () => {
let fakeLocalStorage: JasmineSpyObj;
let fakeGa: jasmine.Spy;
let fakeMonaco;
let fakeGlobal: {[k: string]: any} = {};
const fakeGlobal: {[k: string]: any} = {};

beforeEach(() => {
fakeEditor = jasmine.createSpyObj('editor', [
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('main', () => {
};
fakeMonaco.editor.createModel.and.callFake(
(_: string, language: string) => {
let fakeModel =
const fakeModel =
jasmine.createSpyObj('model', ['getValue', 'setValue']);
fakeModel.getValue.and.returnValue(`fake ${language} source`);
return fakeModel;
Expand Down
26 changes: 21 additions & 5 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
{
"rules": {
"semicolon": [
true
],
"arrow-return-shorthand": true,
"class-name": true,
"file-header": [true, "[*] \\@license\n.* Copyright 20\\d\\d Google Inc\\.\n.*\n.* Licensed under the Apache License, Version 2\\.0 \\(the \"License\"\\);\n.* you may not use this file except in compliance with the License\\.\n.* You may obtain a copy of the License at\n.*\n.* http://www\\.apache\\.org/licenses/LICENSE-2\\.0\n.*\n.* Unless required by applicable law or agreed to in writing, software\n.* distributed under the License is distributed on an \"AS IS\" BASIS,\n.* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\\.\n.* See the License for the specific language governing permissions and\n.* limitations under the License\\."],
"forin": true,
"interface-name": [true, "never-prefix"],
"jsdoc-format": true,
"label-position": true,
"new-parens": true,
"no-console": [true, "log"],
"no-construct": true,
"no-debugger": true,
"no-default-export": true,
"no-duplicate-variable": true,
"no-inferrable-types": [true],
"no-namespace": [true, "allow-declarations"],
"no-unused-expression": true,
"file-header": [true, "[*] \\@license\n.* Copyright 20\\d\\d Google Inc\\.\n.*\n.* Licensed under the Apache License, Version 2\\.0 \\(the \"License\"\\);\n.* you may not use this file except in compliance with the License\\.\n.* You may obtain a copy of the License at\n.*\n.* http://www\\.apache\\.org/licenses/LICENSE-2\\.0\n.*\n.* Unless required by applicable law or agreed to in writing, software\n.* distributed under the License is distributed on an \"AS IS\" BASIS,\n.* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\\.\n.* See the License for the specific language governing permissions and\n.* limitations under the License\\."
]}
"no-var-keyword": true,
"object-literal-shorthand": true,
"prefer-const": true,
"semicolon": [true, "always"],
"variable-name": [true, "check-format", "ban-keywords"]
}
}

0 comments on commit a5cb768

Please sign in to comment.