lint - use single quotes

This commit is contained in:
Benjamin Pasero 2020-01-06 12:27:38 +01:00
parent 68474b90a7
commit bd1042c160
2 changed files with 83 additions and 83 deletions

View file

@ -21,69 +21,69 @@ const minimatch_1 = require("minimatch");
// #############################################################################################
//
const RULES = {
"no-nodejs-globals": [
'no-nodejs-globals': [
{
"target": "**/vs/**/test/{common,browser}/**",
"allowed": [
"process",
"Buffer",
"__filename",
"__dirname"
'target': '**/vs/**/test/{common,browser}/**',
'allowed': [
'process',
'Buffer',
'__filename',
'__dirname'
]
},
{
"target": "**/vs/workbench/api/common/extHostExtensionService.ts",
"allowed": [
"global" // -> safe access to 'global'
'target': '**/vs/workbench/api/common/extHostExtensionService.ts',
'allowed': [
'global' // -> safe access to 'global'
]
},
{
"target": "**/vs/**/{common,browser}/**",
"allowed": [ /* none */]
'target': '**/vs/**/{common,browser}/**',
'allowed': [ /* none */]
}
],
"no-dom-globals": [
'no-dom-globals': [
{
"target": "**/vs/base/parts/quickopen/common/quickOpen.ts",
"allowed": [
"HTMLElement" // quick open will be replaced with a different widget soon
'target': '**/vs/base/parts/quickopen/common/quickOpen.ts',
'allowed': [
'HTMLElement' // quick open will be replaced with a different widget soon
]
},
{
"target": "**/vs/**/test/{common,node,electron-main}/**",
"allowed": [
"document",
"HTMLElement",
"createElement"
'target': '**/vs/**/test/{common,node,electron-main}/**',
'allowed': [
'document',
'HTMLElement',
'createElement'
]
},
{
"target": "**/vs/**/{common,node,electron-main}/**",
"allowed": [ /* none */]
'target': '**/vs/**/{common,node,electron-main}/**',
'allowed': [ /* none */]
}
]
};
const TS_CONFIG_PATH = path_1.join(__dirname, '../../', 'src', 'tsconfig.json');
const DOM_GLOBALS_DEFINITION = 'lib.dom.d.ts';
const DISALLOWED_DOM_GLOBALS = [
"window",
"document",
"HTMLElement",
"createElement"
'window',
'document',
'HTMLElement',
'createElement'
];
const NODE_GLOBALS_DEFINITION = '@types/node';
const DISALLOWED_NODE_GLOBALS = [
// https://nodejs.org/api/globals.html#globals_global_objects
"NodeJS",
"Buffer",
"__dirname",
"__filename",
"clearImmediate",
"exports",
"global",
"module",
"process",
"setImmediate"
'NodeJS',
'Buffer',
'__dirname',
'__filename',
'clearImmediate',
'exports',
'global',
'module',
'process',
'setImmediate'
];
let hasErrors = false;
function checkFile(program, sourceFile, rule) {
@ -127,7 +127,7 @@ function checkFile(program, sourceFile, rule) {
}
function createProgram(tsconfigPath) {
const tsConfig = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
const configHostParser = { fileExists: fs_1.existsSync, readDirectory: ts.sys.readDirectory, readFile: file => fs_1.readFileSync(file, "utf8"), useCaseSensitiveFileNames: process.platform === 'linux' };
const configHostParser = { fileExists: fs_1.existsSync, readDirectory: ts.sys.readDirectory, readFile: file => fs_1.readFileSync(file, 'utf8'), useCaseSensitiveFileNames: process.platform === 'linux' };
const tsConfigParsed = ts.parseJsonConfigFileContent(tsConfig.config, configHostParser, path_1.resolve(path_1.dirname(tsconfigPath)), { noEmit: true });
const compilerHost = ts.createCompilerHost(tsConfigParsed.options, true);
return ts.createProgram(tsConfigParsed.fileNames, tsConfigParsed.options, compilerHost);
@ -139,13 +139,13 @@ const program = createProgram(TS_CONFIG_PATH);
for (const sourceFile of program.getSourceFiles()) {
let noDomGlobalsLinter = undefined;
let noNodeJSGlobalsLinter = undefined;
for (const rules of RULES["no-dom-globals"]) {
for (const rules of RULES['no-dom-globals']) {
if (minimatch_1.match([sourceFile.fileName], rules.target).length > 0) {
noDomGlobalsLinter = { allowed: rules.allowed };
break;
}
}
for (const rules of RULES["no-nodejs-globals"]) {
for (const rules of RULES['no-nodejs-globals']) {
if (minimatch_1.match([sourceFile.fileName], rules.target).length > 0) {
noNodeJSGlobalsLinter = { allowed: rules.allowed };
break;

View file

@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as ts from "typescript";
import { readFileSync, existsSync } from "fs";
import { resolve, dirname, join } from "path";
import * as ts from 'typescript';
import { readFileSync, existsSync } from 'fs';
import { resolve, dirname, join } from 'path';
import { match } from 'minimatch';
//
@ -22,45 +22,45 @@ import { match } from 'minimatch';
//
const RULES = {
"no-nodejs-globals": [
'no-nodejs-globals': [
{
"target": "**/vs/**/test/{common,browser}/**",
"allowed": [ // -> less strict for test files
"process",
"Buffer",
"__filename",
"__dirname"
'target': '**/vs/**/test/{common,browser}/**',
'allowed': [ // -> less strict for test files
'process',
'Buffer',
'__filename',
'__dirname'
]
},
{
"target": "**/vs/workbench/api/common/extHostExtensionService.ts",
"allowed": [
"global" // -> safe access to 'global'
'target': '**/vs/workbench/api/common/extHostExtensionService.ts',
'allowed': [
'global' // -> safe access to 'global'
]
},
{
"target": "**/vs/**/{common,browser}/**",
"allowed": [ /* none */]
'target': '**/vs/**/{common,browser}/**',
'allowed': [ /* none */]
}
],
"no-dom-globals": [
'no-dom-globals': [
{
"target": "**/vs/base/parts/quickopen/common/quickOpen.ts",
"allowed": [
"HTMLElement" // quick open will be replaced with a different widget soon
'target': '**/vs/base/parts/quickopen/common/quickOpen.ts',
'allowed': [
'HTMLElement' // quick open will be replaced with a different widget soon
]
},
{
"target": "**/vs/**/test/{common,node,electron-main}/**",
"allowed": [ // -> less strict for test files
"document",
"HTMLElement",
"createElement"
'target': '**/vs/**/test/{common,node,electron-main}/**',
'allowed': [ // -> less strict for test files
'document',
'HTMLElement',
'createElement'
]
},
{
"target": "**/vs/**/{common,node,electron-main}/**",
"allowed": [ /* none */]
'target': '**/vs/**/{common,node,electron-main}/**',
'allowed': [ /* none */]
}
]
};
@ -70,26 +70,26 @@ const TS_CONFIG_PATH = join(__dirname, '../../', 'src', 'tsconfig.json');
const DOM_GLOBALS_DEFINITION = 'lib.dom.d.ts';
const DISALLOWED_DOM_GLOBALS = [
"window",
"document",
"HTMLElement",
"createElement"
'window',
'document',
'HTMLElement',
'createElement'
];
const NODE_GLOBALS_DEFINITION = '@types/node';
const DISALLOWED_NODE_GLOBALS = [
// https://nodejs.org/api/globals.html#globals_global_objects
"NodeJS",
"Buffer",
"__dirname",
"__filename",
"clearImmediate",
"exports",
"global",
"module",
"process",
"setImmediate"
'NodeJS',
'Buffer',
'__dirname',
'__filename',
'clearImmediate',
'exports',
'global',
'module',
'process',
'setImmediate'
];
interface IRule {
@ -150,7 +150,7 @@ function checkFile(program: ts.Program, sourceFile: ts.SourceFile, rule: IRule)
function createProgram(tsconfigPath: string): ts.Program {
const tsConfig = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
const configHostParser: ts.ParseConfigHost = { fileExists: existsSync, readDirectory: ts.sys.readDirectory, readFile: file => readFileSync(file, "utf8"), useCaseSensitiveFileNames: process.platform === 'linux' };
const configHostParser: ts.ParseConfigHost = { fileExists: existsSync, readDirectory: ts.sys.readDirectory, readFile: file => readFileSync(file, 'utf8'), useCaseSensitiveFileNames: process.platform === 'linux' };
const tsConfigParsed = ts.parseJsonConfigFileContent(tsConfig.config, configHostParser, resolve(dirname(tsconfigPath)), { noEmit: true });
const compilerHost = ts.createCompilerHost(tsConfigParsed.options, true);
@ -167,14 +167,14 @@ for (const sourceFile of program.getSourceFiles()) {
let noDomGlobalsLinter: { allowed: string[] } | undefined = undefined;
let noNodeJSGlobalsLinter: { allowed: string[] } | undefined = undefined;
for (const rules of RULES["no-dom-globals"]) {
for (const rules of RULES['no-dom-globals']) {
if (match([sourceFile.fileName], rules.target).length > 0) {
noDomGlobalsLinter = { allowed: rules.allowed };
break;
}
}
for (const rules of RULES["no-nodejs-globals"]) {
for (const rules of RULES['no-nodejs-globals']) {
if (match([sourceFile.fileName], rules.target).length > 0) {
noNodeJSGlobalsLinter = { allowed: rules.allowed };
break;