diff --git a/packages/analyzer/src/core/analyzer.ts b/packages/analyzer/src/core/analyzer.ts index 412c3ed4b..2077f80b4 100644 --- a/packages/analyzer/src/core/analyzer.ts +++ b/packages/analyzer/src/core/analyzer.ts @@ -64,7 +64,7 @@ export interface AnalyzeOptions { */ export interface ForkOptions { urlLoader?: UrlLoader; } -export class NoKnownParserError extends Error {}; +export class NoKnownParserError extends Error {} export type ScannerTable = Map[]>; export type LazyEdgeMap = Map; diff --git a/packages/analyzer/src/css/css-custom-property-scanner.ts b/packages/analyzer/src/css/css-custom-property-scanner.ts index b0e15dbce..14a49bf7e 100644 --- a/packages/analyzer/src/css/css-custom-property-scanner.ts +++ b/packages/analyzer/src/css/css-custom-property-scanner.ts @@ -129,4 +129,4 @@ function* findAllMatchesInString(regex: RegExp, haystack: string) { while (match = regex.exec(haystack)) { yield {offset: match.index, matched: match[0]}; } -}; +} diff --git a/packages/analyzer/src/demo/polymer-lint.ts b/packages/analyzer/src/demo/polymer-lint.ts index 12d5311c6..0cebc99e1 100644 --- a/packages/analyzer/src/demo/polymer-lint.ts +++ b/packages/analyzer/src/demo/polymer-lint.ts @@ -28,7 +28,7 @@ async function main() { if (worstSeverity === Severity.ERROR) { process.exit(1); } -}; +} async function getWarnings( analyzer: Analyzer, localPath: string): Promise { diff --git a/packages/analyzer/src/javascript/function-scanner.ts b/packages/analyzer/src/javascript/function-scanner.ts index 6478f2b7c..520ca5189 100644 --- a/packages/analyzer/src/javascript/function-scanner.ts +++ b/packages/analyzer/src/javascript/function-scanner.ts @@ -114,7 +114,7 @@ class FunctionVisitor implements Visitor { docNode?: babel.Node) { if (docNode === undefined) { docNode = node; - }; + } const docs = jsdoc.parseJsdoc(getAttachedComment(docNode) || ''); // The @function annotation can override the name. diff --git a/packages/analyzer/src/javascript/resolve-specifier-node.ts b/packages/analyzer/src/javascript/resolve-specifier-node.ts index aca5d862b..7229ef930 100644 --- a/packages/analyzer/src/javascript/resolve-specifier-node.ts +++ b/packages/analyzer/src/javascript/resolve-specifier-node.ts @@ -82,8 +82,9 @@ export const resolve = } } - let relativeSpecifierUrl = relative( - dirname(effectiveDocumentPath), resolvedSpecifier) as FileRelativeUrl; + let relativeSpecifierUrl = + relative(dirname(effectiveDocumentPath), resolvedSpecifier) as + FileRelativeUrl; if (isWindows()) { // normalize path separators to URL format diff --git a/packages/analyzer/src/json/json-document.ts b/packages/analyzer/src/json/json-document.ts index 1a10fc025..a9603321f 100644 --- a/packages/analyzer/src/json/json-document.ts +++ b/packages/analyzer/src/json/json-document.ts @@ -31,7 +31,7 @@ export class ParsedJsonDocument extends ParsedDocument { private _visit(node: Json, visitors: Visitor[]) { for (const visitor of visitors) { visitor.visit(node); - }; + } if (Array.isArray(node)) { for (const value of node) { this._visit(value, visitors); diff --git a/packages/analyzer/src/model/inline-document.ts b/packages/analyzer/src/model/inline-document.ts index d49f9208e..98001af52 100644 --- a/packages/analyzer/src/model/inline-document.ts +++ b/packages/analyzer/src/model/inline-document.ts @@ -43,7 +43,7 @@ export interface HtmlAstNode { node: dom5.Node; containingDocument: ParsedHtmlDocument; } -; + export interface JsAstNode { language: 'js'; diff --git a/packages/analyzer/src/perf/parse-all-benchmark.ts b/packages/analyzer/src/perf/parse-all-benchmark.ts index b3effc4f5..ad797c140 100644 --- a/packages/analyzer/src/perf/parse-all-benchmark.ts +++ b/packages/analyzer/src/perf/parse-all-benchmark.ts @@ -126,7 +126,7 @@ async function measure() { `\n==========================================\n\n`); process.exit(1); } -}; +} function printMeasurements(measurements: number[]) { console.log(`\n\n\n\n diff --git a/packages/analyzer/src/polymer/analyze-properties.ts b/packages/analyzer/src/polymer/analyze-properties.ts index b8161b234..efbb98584 100644 --- a/packages/analyzer/src/polymer/analyze-properties.ts +++ b/packages/analyzer/src/polymer/analyze-properties.ts @@ -171,4 +171,4 @@ export function analyzeProperties( analyzedProps.push(prop); } return analyzedProps; -}; +} diff --git a/packages/analyzer/src/polymer/js-utils.ts b/packages/analyzer/src/polymer/js-utils.ts index b21c0856d..000ef53f9 100644 --- a/packages/analyzer/src/polymer/js-utils.ts +++ b/packages/analyzer/src/polymer/js-utils.ts @@ -71,4 +71,4 @@ export function toScannedPolymerProperty( }; return result; -}; +} diff --git a/packages/analyzer/src/scanning/scan.ts b/packages/analyzer/src/scanning/scan.ts index 4f25b50fd..74449b9ab 100644 --- a/packages/analyzer/src/scanning/scan.ts +++ b/packages/analyzer/src/scanning/scan.ts @@ -69,7 +69,7 @@ scan>( // Let `scan` continue after calls to visit().then() currentDoneCallback(); } - }; + } // The callback passed to `scan()` function visit(visitor: Visitor) { @@ -81,7 +81,7 @@ scan>( }); } return visitorsPromise; - }; + } // Ok, go! setup(); diff --git a/packages/analyzer/src/test/core/analyzer_test.ts b/packages/analyzer/src/test/core/analyzer_test.ts index 5d8b0bba8..3a1a85d50 100644 --- a/packages/analyzer/src/test/core/analyzer_test.ts +++ b/packages/analyzer/src/test/core/analyzer_test.ts @@ -68,7 +68,7 @@ suite('Analyzer', () => { throw new Error(`Could not get document for url: ${url}`); } return result.value; - }; + } setup(() => { const underlyingUrlLoader = new FsUrlLoader(testDir); @@ -1366,4 +1366,4 @@ var DuplicateNamespace = {}; async function getContext(analyzer: Analyzer) { return await analyzer['_analysisComplete']; -}; +} diff --git a/packages/analyzer/src/test/core/dependency-graph_test.ts b/packages/analyzer/src/test/core/dependency-graph_test.ts index 653da7b58..4d959c3f6 100644 --- a/packages/analyzer/src/test/core/dependency-graph_test.ts +++ b/packages/analyzer/src/test/core/dependency-graph_test.ts @@ -78,7 +78,7 @@ suite('DependencyGraph', () => { assertStringSetsEqual( graph.getAllDependantsOf(analyzer.resolveUrl(path)!), expectedDependants.map((u) => analyzer.resolveUrl(u)!)); - }; + } test('works with a basic document with no dependencies', async () => { await analyzer.analyze(['dependencies/leaf.html']); diff --git a/packages/analyzer/src/test/javascript/class-scanner_test.ts b/packages/analyzer/src/test/javascript/class-scanner_test.ts index 24d81e27a..850c6b525 100644 --- a/packages/analyzer/src/test/javascript/class-scanner_test.ts +++ b/packages/analyzer/src/test/javascript/class-scanner_test.ts @@ -25,18 +25,18 @@ suite('Class', async () => { async function getScannedFeatures(filename: string) { const {features} = await runScanner(analyzer, new ClassScanner(), filename); return features; - }; + } async function getScannedClasses(filename: string): Promise { const features = await getScannedFeatures(filename); return features.filter((e) => e instanceof ScannedClass) as ScannedClass[]; - }; + } async function getClasses(filename: string) { const analysis = await analyzer.analyze([filename]); const classes = Array.from(analysis.getFeatures({kind: 'class'})); return {classes, analysis}; - }; + } async function getTestProps(class_: ScannedClass|Class) { type TestPropsType = { @@ -105,7 +105,7 @@ suite('Class', async () => { result.superClass = class_.superClass.identifier; } return result; - }; + } suite('scanning', () => { test('finds classes and their names and comment blocks', async () => { diff --git a/packages/analyzer/src/test/javascript/function-scanner_test.ts b/packages/analyzer/src/test/javascript/function-scanner_test.ts index 711d392f8..3ebb9f5da 100644 --- a/packages/analyzer/src/test/javascript/function-scanner_test.ts +++ b/packages/analyzer/src/test/javascript/function-scanner_test.ts @@ -34,7 +34,7 @@ suite('FunctionScanner', async () => { } } return scannedFunctions; - }; + } async function getTestProps(fn: ScannedFunction): Promise { diff --git a/packages/analyzer/src/test/javascript/namespace-scanner_test.ts b/packages/analyzer/src/test/javascript/namespace-scanner_test.ts index c6b47e362..dc001abb6 100644 --- a/packages/analyzer/src/test/javascript/namespace-scanner_test.ts +++ b/packages/analyzer/src/test/javascript/namespace-scanner_test.ts @@ -34,7 +34,7 @@ suite('NamespaceScanner', async () => { } } return scannedNamespaces; - }; + } function getProperties(namespace: ScannedNamespace) { return [...namespace.properties.values()].map((prop) => { diff --git a/packages/analyzer/src/test/javascript/resolve-specifier-node_test.ts b/packages/analyzer/src/test/javascript/resolve-specifier-node_test.ts index 67d347020..25c632529 100644 --- a/packages/analyzer/src/test/javascript/resolve-specifier-node_test.ts +++ b/packages/analyzer/src/test/javascript/resolve-specifier-node_test.ts @@ -45,50 +45,49 @@ const scopedRootComponentInfo = { componentDir }; -suite('resolve', async() => { - - test('non-component root to shallow dep', async() => { +suite('resolve', async () => { + test('non-component root to shallow dep', async () => { assert.equal( resolve('shallow', rootMain), './node_modules/shallow/shallow.js'); }); - test('non-component root to scoped dep', async() => { + test('non-component root to scoped dep', async () => { assert.equal( resolve('@scope/scoped', rootMain), './node_modules/@scope/scoped/scoped.js'); }); - test('shallow dep to scoped dep', async() => { + test('shallow dep to scoped dep', async () => { assert.equal( resolve('@scope/scoped', shallowDepMain, shallowRootComponentInfo), '../@scope/scoped/scoped.js'); }); - test('scoped dep to shallow dep', async() => { + test('scoped dep to shallow dep', async () => { assert.equal( resolve('shallow', scopedDepMain, shallowRootComponentInfo), '../../shallow/shallow.js'); }); - test('component-root to shallow dep', async() => { + test('component-root to shallow dep', async () => { assert.equal( resolve('shallow', rootMain, shallowRootComponentInfo), '../shallow/shallow.js'); }); - test('component-root to scoped dep', async() => { + test('component-root to scoped dep', async () => { assert.equal( resolve('@scope/scoped', rootMain, shallowRootComponentInfo), '../@scope/scoped/scoped.js'); }); - test('scoped-component-root to shallow dep', async() => { + test('scoped-component-root to shallow dep', async () => { assert.equal( resolve('shallow', rootMain, scopedRootComponentInfo), '../../shallow/shallow.js'); }); - test('scoped-component-root to scoped dep', async() => { + test('scoped-component-root to scoped dep', async () => { assert.equal( resolve('@scope/scoped', rootMain, scopedRootComponentInfo), '../scoped/scoped.js'); diff --git a/packages/analyzer/src/test/model/warning_test.ts b/packages/analyzer/src/test/model/warning_test.ts index bbcc7ba60..f5190ce59 100644 --- a/packages/analyzer/src/test/model/warning_test.ts +++ b/packages/analyzer/src/test/model/warning_test.ts @@ -46,7 +46,7 @@ suite('applyEdits', () => { }, replacementText }; - }; + } test('works in the trivial case', async () => { const contents = 'abc'; diff --git a/packages/analyzer/src/test/polymer/polymer-element-old-jsdoc_test.ts b/packages/analyzer/src/test/polymer/polymer-element-old-jsdoc_test.ts index 02858f588..95768e003 100644 --- a/packages/analyzer/src/test/polymer/polymer-element-old-jsdoc_test.ts +++ b/packages/analyzer/src/test/polymer/polymer-element-old-jsdoc_test.ts @@ -39,7 +39,7 @@ suite('PolymerElement with old jsdoc annotations', () => { } const elements = result.value.getFeatures({kind: 'polymer-element'}); return elements; - }; + } function getTestProps(element: PolymerElement): any { return { diff --git a/packages/analyzer/src/test/polymer/polymer-element_test.ts b/packages/analyzer/src/test/polymer/polymer-element_test.ts index 7480da8ff..bf6b9e881 100644 --- a/packages/analyzer/src/test/polymer/polymer-element_test.ts +++ b/packages/analyzer/src/test/polymer/polymer-element_test.ts @@ -32,7 +32,7 @@ suite('PolymerElement', async () => { const document = result.value; const elements = document.getFeatures({kind: 'polymer-element'}); return elements; - }; + } function getTestProps(element: PolymerElement): any { return { diff --git a/packages/analyzer/src/test/polymer/polymer2-element-scanner-old-jsdoc_test.ts b/packages/analyzer/src/test/polymer/polymer2-element-scanner-old-jsdoc_test.ts index 5b8942bce..bd2ef7b51 100644 --- a/packages/analyzer/src/test/polymer/polymer2-element-scanner-old-jsdoc_test.ts +++ b/packages/analyzer/src/test/polymer/polymer2-element-scanner-old-jsdoc_test.ts @@ -31,7 +31,7 @@ suite('Polymer2ElementScanner with old jsdoc annotations', async () => { const {features} = await runScanner(analyzer, new ClassScanner(), filename); return features.filter((e) => e instanceof ScannedPolymerElement) as ScannedPolymerElement[]; - }; + } async function getTestProps(element: ScannedPolymerElement): Promise { const props: any = { diff --git a/packages/analyzer/src/test/polymer/polymer2-element-scanner_test.ts b/packages/analyzer/src/test/polymer/polymer2-element-scanner_test.ts index 9453d8442..aa1a108c9 100644 --- a/packages/analyzer/src/test/polymer/polymer2-element-scanner_test.ts +++ b/packages/analyzer/src/test/polymer/polymer2-element-scanner_test.ts @@ -33,7 +33,7 @@ suite('Polymer2ElementScanner', async () => { return features.filter((e) => e instanceof ScannedPolymerElement) as ScannedPolymerElement[]; - }; + } async function getTestProps(element: ScannedPolymerElement): Promise { const props: any = { diff --git a/packages/analyzer/src/test/polymer/polymer2-mixin-scanner-old-jsdoc_test.ts b/packages/analyzer/src/test/polymer/polymer2-mixin-scanner-old-jsdoc_test.ts index e07ffef3d..cadea29ea 100644 --- a/packages/analyzer/src/test/polymer/polymer2-mixin-scanner-old-jsdoc_test.ts +++ b/packages/analyzer/src/test/polymer/polymer2-mixin-scanner-old-jsdoc_test.ts @@ -28,12 +28,12 @@ suite('Polymer2MixinScanner with old jsdoc annotations', async () => { const {features} = await runScanner(analyzer, new ClassScanner(), filename); return features.filter( (e) => e instanceof ScannedPolymerElementMixin); - }; + } async function getMixins(filename: string) { const analysis = await analyzer.analyze([filename]); return Array.from(analysis.getFeatures({kind: 'polymer-element-mixin'})); - }; + } async function getTestProps(mixin: ScannedPolymerElementMixin| PolymerElementMixin) { diff --git a/packages/analyzer/src/test/polymer/polymer2-mixin-scanner_test.ts b/packages/analyzer/src/test/polymer/polymer2-mixin-scanner_test.ts index e0f4d315e..3c41804ce 100644 --- a/packages/analyzer/src/test/polymer/polymer2-mixin-scanner_test.ts +++ b/packages/analyzer/src/test/polymer/polymer2-mixin-scanner_test.ts @@ -28,12 +28,12 @@ suite('Polymer2MixinScanner', async () => { const {features} = await runScanner(analyzer, new ClassScanner(), filename); return features.filter( (e) => e instanceof ScannedPolymerElementMixin); - }; + } async function getMixins(filename: string) { const analysis = await analyzer.analyze([filename]); return Array.from(analysis.getFeatures({kind: 'polymer-element-mixin'})); - }; + } async function getTestProps(mixin: ScannedPolymerElementMixin| PolymerElementMixin) { diff --git a/packages/analyzer/tslint.json b/packages/analyzer/tslint.json index 84f54ee5c..40a18cdec 100644 --- a/packages/analyzer/tslint.json +++ b/packages/analyzer/tslint.json @@ -1,60 +1,3 @@ { - "rules": { - "arrow-parens": true, - "class-name": true, - "indent": [ - true, - "spaces" - ], - "prefer-const": true, - "no-duplicate-variable": true, - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "semicolon": [ - true, - "always" - ], - "trailing-comma": [ - true, - "multiline" - ], - "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" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } + "extends": "../../tslint.json" } diff --git a/packages/browser-capabilities/src/browser-capabilities.ts b/packages/browser-capabilities/src/browser-capabilities.ts index 6deb2ef35..8dabeee9d 100644 --- a/packages/browser-capabilities/src/browser-capabilities.ts +++ b/packages/browser-capabilities/src/browser-capabilities.ts @@ -103,7 +103,7 @@ export function browserCapabilities(userAgent: string): Set { if (predicates[capability](ua)) { capabilities.add(capability); } - }; + } return capabilities; } diff --git a/packages/browser-capabilities/tslint.json b/packages/browser-capabilities/tslint.json new file mode 100644 index 000000000..0946f2096 --- /dev/null +++ b/packages/browser-capabilities/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tslint.json" +} diff --git a/packages/build/src/html-splitter.ts b/packages/build/src/html-splitter.ts index 628b4bcf1..87b407d1a 100644 --- a/packages/build/src/html-splitter.ts +++ b/packages/build/src/html-splitter.ts @@ -98,7 +98,7 @@ export function scriptWasSplitByHtmlSplitter(script: dom5.Node): boolean { export type HtmlSplitterFile = File&{ fromHtmlSplitter?: true; moduleScriptIdx?: number -} +}; /** * Return whether the given Vinyl file was created by the HtmlSplitter from an diff --git a/packages/build/tslint.json b/packages/build/tslint.json index 84f54ee5c..2584c4755 100644 --- a/packages/build/tslint.json +++ b/packages/build/tslint.json @@ -1,60 +1,3 @@ { - "rules": { - "arrow-parens": true, - "class-name": true, - "indent": [ - true, - "spaces" - ], - "prefer-const": true, - "no-duplicate-variable": true, - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "semicolon": [ - true, - "always" - ], - "trailing-comma": [ - true, - "multiline" - ], - "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" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } -} + "extends": "../../tslint.json" + } diff --git a/packages/bundler/src/es6-module-bundler.ts b/packages/bundler/src/es6-module-bundler.ts index 3d6d52215..6c419af15 100644 --- a/packages/bundler/src/es6-module-bundler.ts +++ b/packages/bundler/src/es6-module-bundler.ts @@ -64,7 +64,7 @@ export async function bundle( async function prepareBundleModule( bundler: Bundler, manifest: BundleManifest, assignedBundle: AssignedBundle): Promise { - let bundleSource = babel.program([]); + const bundleSource = babel.program([]); const sourceAnalysis = await bundler.analyzer.analyze([...assignedBundle.bundle.files]); for (const sourceUrl of [...assignedBundle.bundle.files].sort()) { diff --git a/packages/bundler/src/es6-module-utils.ts b/packages/bundler/src/es6-module-utils.ts index c72e0196d..88f9edb19 100644 --- a/packages/bundler/src/es6-module-utils.ts +++ b/packages/bundler/src/es6-module-utils.ts @@ -33,7 +33,7 @@ export function getOrSetBundleModuleExportName( let exportName = moduleExports.get(name); if (!exportName) { let trialName = name; - let moduleFileNameIdentifier = + const moduleFileNameIdentifier = '$' + camelCase(getFileName(moduleUrl).replace(/\.[a-z0-9_]+$/, '')); trialName = trialName.replace(/^default$/, `${moduleFileNameIdentifier}Default`) diff --git a/packages/bundler/src/html-bundler.ts b/packages/bundler/src/html-bundler.ts index 33bcee0a8..b70c9e28f 100644 --- a/packages/bundler/src/html-bundler.ts +++ b/packages/bundler/src/html-bundler.ts @@ -110,8 +110,8 @@ export class HtmlBundler { oldBaseUrl: ResolvedUrl) { const inlineScripts = dom5.queryAll(reparsedDoc.ast, matchers.inlineNonModuleScript); - const promises = inlineScripts.map(scriptAst => { - let content = dom5.getTextContent(scriptAst); + const promises = inlineScripts.map((scriptAst) => { + const content = dom5.getTextContent(scriptAst); const sourceRange = reparsedDoc.sourceRangeForStartTag(scriptAst)!; return addOrUpdateSourcemapComment( this.bundler.analyzer, @@ -121,7 +121,7 @@ export class HtmlBundler { sourceRange.end.column, -sourceRange.end.line + 1, -sourceRange.end.column) - .then(updatedContent => { + .then((updatedContent) => { dom5.setTextContent(scriptAst, encodeString(updatedContent)); }); }); diff --git a/packages/bundler/src/source-map.ts b/packages/bundler/src/source-map.ts index 990ce69b0..ad1ea64d0 100644 --- a/packages/bundler/src/source-map.ts +++ b/packages/bundler/src/source-map.ts @@ -52,11 +52,11 @@ function createJsIdentitySourcemap( const generator = new SourceMapGenerator(); const tokens = espree.tokenize( sourceContent, {loc: true, ecmaVersion: 2017, sourceType: 'module'}); - tokens.forEach(token => { + tokens.forEach((token) => { if (!token.loc) { return null; } - let mapping: any = { + const mapping: any = { original: { line: token.loc.start.line + lineOffset, column: token.loc.start.column + @@ -81,7 +81,7 @@ function offsetSourceMap( const consumer = new SourceMapConsumer(sourcemap); const generator = new SourceMapGenerator(); - consumer.eachMapping(mapping => { + consumer.eachMapping((mapping) => { const newMapping: any = { source: mapping.source, generated: { @@ -131,7 +131,7 @@ export async function getExistingSourcemap( // Rewrite the sources array to be relative to the current URL if (sourcemap.sources) { sourcemap.sources = - sourcemap.sources.map(source => urlLib.resolve(mapUrl, source)); + sourcemap.sources.map((source) => urlLib.resolve(mapUrl, source)); } return sourcemap; } @@ -219,7 +219,7 @@ export function updateSourcemapLocations( }); const inlineScripts = dom5.queryAll(ast, matchers.nonModuleScript); - inlineScripts.forEach(script => { + inlineScripts.forEach((script) => { let content = dom5.getTextContent(script); const sourceMapUrlParts = content.match(sourceMappingUrlExpr); diff --git a/packages/bundler/src/test/shards_test.ts b/packages/bundler/src/test/shards_test.ts index a3c0fd902..90ea86478 100644 --- a/packages/bundler/src/test/shards_test.ts +++ b/packages/bundler/src/test/shards_test.ts @@ -82,11 +82,11 @@ suite('Bundler', () => { doc: parse5.ASTNode, contains: dom5.Predicate[], excludes: dom5.Predicate[]) { - for (let test of contains) { + for (const test of contains) { const found = dom5.queryAll(doc, test); assert.equal(found.length, 1); } - for (let test of excludes) { + for (const test of excludes) { const found = dom5.queryAll(doc, test); assert.equal(found.length, 0); } diff --git a/packages/bundler/src/test/sourcemap_test.ts b/packages/bundler/src/test/sourcemap_test.ts index 54be27719..1a7ab9476 100644 --- a/packages/bundler/src/test/sourcemap_test.ts +++ b/packages/bundler/src/test/sourcemap_test.ts @@ -60,7 +60,7 @@ suite('Bundler', () => { const consumer = new SourceMapConsumer(sourcemap!); let foundMapping = false; const mappings: MappingItem[] = []; - consumer.eachMapping(mapping => mappings.push(mapping)); + consumer.eachMapping((mapping) => mappings.push(mapping)); for (let j = 0; j < mappings.length; j++) { if (mappings[j].name === name) { foundMapping = true; diff --git a/packages/bundler/tslint.json b/packages/bundler/tslint.json index dee79e1eb..40a18cdec 100644 --- a/packages/bundler/tslint.json +++ b/packages/bundler/tslint.json @@ -1,59 +1,3 @@ { - "rules": { - "class-name": true, - "indent": [ - true, - "spaces" - ], - "no-duplicate-variable": true, - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-unused-variable": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "semicolon": [ - true, - "always" - ], - "trailing-comma": [ - true, - "multiline" - ], - "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" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } + "extends": "../../tslint.json" } diff --git a/packages/cli/src/init/application/application.ts b/packages/cli/src/init/application/application.ts index 117de6fea..0a2116ef8 100644 --- a/packages/cli/src/init/application/application.ts +++ b/packages/cli/src/init/application/application.ts @@ -115,7 +115,7 @@ export function createApplicationGenerator(templateName: string): this.log( 'Check out your new project README for information about what to do next.\n'); } - }; + } class Polymer3ApplicationGenerator extends ApplicationGenerator { // TODO(yeoman/generator#1065): This function is not a no-op: Yeoman only diff --git a/packages/cli/src/init/element/element.ts b/packages/cli/src/init/element/element.ts index b818c890a..4ad6d9692 100644 --- a/packages/cli/src/init/element/element.ts +++ b/packages/cli/src/init/element/element.ts @@ -118,7 +118,7 @@ export function createElementGenerator(templateName: string): this.log( 'Check out your new project README for information about what to do next.\n'); } - }; + } class Polymer3ElementGenerator extends ElementGenerator { // TODO(yeoman/generator#1065): This function is not a no-op: Yeoman only diff --git a/packages/cli/src/test/integration/lint_test.ts b/packages/cli/src/test/integration/lint_test.ts index caae1a437..ead8825eb 100644 --- a/packages/cli/src/test/integration/lint_test.ts +++ b/packages/cli/src/test/integration/lint_test.ts @@ -300,7 +300,7 @@ function copyDir(fromDir: string, toDir: string) { fs.writeFileSync(toInner, fs.readFileSync(fromInner)); } } -}; +} /** Simple class for reading up to a delimitor in an unending stream. */ class StreamReader { diff --git a/packages/cli/src/test/integration/run-command.ts b/packages/cli/src/test/integration/run-command.ts index ece89fb96..b3348f3a1 100644 --- a/packages/cli/src/test/integration/run-command.ts +++ b/packages/cli/src/test/integration/run-command.ts @@ -53,7 +53,7 @@ export async function runCommand( if (options.failureExpected) { // Throw the output string as our error if failure is expected. throw out; - }; + } console.log( `Output of failed command 'node ${path} ${args.join(' ')}' ` + diff --git a/packages/cli/tslint.json b/packages/cli/tslint.json index 62845b0da..40a18cdec 100644 --- a/packages/cli/tslint.json +++ b/packages/cli/tslint.json @@ -1,5 +1,3 @@ { - "extends": [ - "@polymer/tools-common/tslint.json" - ] + "extends": "../../tslint.json" } diff --git a/packages/editor-service/src/language-server/analyzer-synchronizer.ts b/packages/editor-service/src/language-server/analyzer-synchronizer.ts index 44255fb69..979d5fa4b 100644 --- a/packages/editor-service/src/language-server/analyzer-synchronizer.ts +++ b/packages/editor-service/src/language-server/analyzer-synchronizer.ts @@ -69,7 +69,7 @@ export default class AnalyzerSynchronizer extends AutoDisposable { // the Settings change stream here for it, in order to avoid doing duplicate // work. fileChangeEvents = fileChangeEvents.filter( - change => + (change) => this.converter.getWorkspacePathToFile(change) !== 'polymer.json'); if (fileChangeEvents.length === 0) { return; // no new information in this notification diff --git a/packages/editor-service/src/language-server/auto-completer.ts b/packages/editor-service/src/language-server/auto-completer.ts index 8143e9724..146a3cbb9 100644 --- a/packages/editor-service/src/language-server/auto-completer.ts +++ b/packages/editor-service/src/language-server/auto-completer.ts @@ -171,7 +171,7 @@ export default class AutoCompleter extends Handler { imported: true, externalPackages: true }); - const names = new Set([...propertyAssignments].map(a => a.name)); + const names = new Set([...propertyAssignments].map((a) => a.name)); const items = [...names].sort().map((name): CompletionItem => { return {label: name, kind: CompletionItemKind.Variable}; }); @@ -203,11 +203,11 @@ export default class AutoCompleter extends Handler { const elements = [ ...document.getFeatures( {kind: 'element', externalPackages: true, imported: true}) - ].filter(e => e.tagName); + ].filter((e) => e.tagName); const prefix = location.kind === 'tagName' ? '' : '<'; - const items = elements.map(e => { + const items = elements.map((e) => { const tagName = e.tagName!; - let item: CompletionItem = { + const item: CompletionItem = { label: `<${tagName}>`, documentation: this.documentationFromMarkdown(e.description), filterText: tagName.replace(/-/g, ''), @@ -284,10 +284,10 @@ export default class AutoCompleter extends Handler { const attributeValue = dom5.getAttribute(location.element, innerAttribute.name)!; const hasDelimeters = /^\s*(\{\{|\[\[)/.test(attributeValue); - const attributes = [...outerElement.properties.values()].map(p => { + const attributes = [...outerElement.properties.values()].map((p) => { const sortText = (sortPrefixes.get(p.inheritedFrom) || `ddd-`) + p.name; let autocompletion; - let autocompletionSnippet; + const autocompletionSnippet = undefined; if (attributeValue && hasDelimeters) { autocompletion = p.name; } else { @@ -369,10 +369,10 @@ export default class AutoCompleter extends Handler { externalPackages: true, imported: true }); - let attributes: AttributeCompletion[] = []; + const attributes: AttributeCompletion[] = []; if (element) { const sortPrefixes = this.createSortPrefixes(element); - attributes.push(...[...element.attributes.values()].map(p => { + attributes.push(...[...element.attributes.values()].map((p) => { const sortText = (sortPrefixes.get(p.inheritedFrom) || `ddd-`) + p.name; return { label: p.name, @@ -450,7 +450,7 @@ export default class AutoCompleter extends Handler { completions: CompletionList, position: SourcePosition, document: Document): CompletionList { const leadingText = this.getLeadingIdentifier(position, document); - const filterableCompletions = completions.items.map(completion => { + const filterableCompletions = completions.items.map((completion) => { return { filterText: completion.filterText || completion.label, completion @@ -459,7 +459,7 @@ export default class AutoCompleter extends Handler { const items = fuzzaldrin .filter(filterableCompletions, leadingText, {key: 'filterText'}) - .map(i => i.completion); + .map((i) => i.completion); return {isIncomplete: true, items}; } diff --git a/packages/editor-service/src/language-server/definition-finder.ts b/packages/editor-service/src/language-server/definition-finder.ts index 6a7d25d90..81374d325 100644 --- a/packages/editor-service/src/language-server/definition-finder.ts +++ b/packages/editor-service/src/language-server/definition-finder.ts @@ -107,7 +107,7 @@ export default class DefinitionFinder extends Handler { id: feature.name, externalPackages: true }); - return [...assignments].map(a => a.sourceRange); + return [...assignments].map((a) => a.sourceRange); } if (feature instanceof DatabindingFeature) { if (feature.property && feature.property.sourceRange) { @@ -159,7 +159,7 @@ export default class DefinitionFinder extends Handler { kind: 'css-custom-property-use', id: featureResult.feature.name })]; - locations.push(...propertyUses.map(f => { + locations.push(...propertyUses.map((f) => { return { uri: f.sourceRange.file, range: this.converter.convertPRangeToL(f.sourceRange) @@ -172,8 +172,8 @@ export default class DefinitionFinder extends Handler { kind: 'element-reference', id: astResult.node.element.tagName!, externalPackages: true, - })].map(e => e.sourceRange); - locations.push(...ranges.map(r => { + })].map((e) => e.sourceRange); + locations.push(...ranges.map((r) => { return {uri: r.file, range: this.converter.convertPRangeToL(r)}; })); } diff --git a/packages/editor-service/src/language-server/diagnostics.ts b/packages/editor-service/src/language-server/diagnostics.ts index 86da40e32..1b4e567d8 100644 --- a/packages/editor-service/src/language-server/diagnostics.ts +++ b/packages/editor-service/src/language-server/diagnostics.ts @@ -107,7 +107,7 @@ export default class DiagnosticGenerator extends Handler { } // A fix can touch multiple files. We can only update this document // though, so skip any fixes that touch others. - if (warning.fix.some(repl => repl.range.file !== uri)) { + if (warning.fix.some((repl) => repl.range.file !== uri)) { continue; } edits.push(warning.fix); @@ -148,7 +148,7 @@ export default class DiagnosticGenerator extends Handler { this.warningCodesToFilterOut = new Set(lintConfig.ignoreWarnings); this.fileGlobsToFilterOut = (lintConfig.filesToIgnore || - []).map(glob => new minimatch.Minimatch(glob, {})); + []).map((glob) => new minimatch.Minimatch(glob, {})); } const polymerJsonDiagnostics = []; @@ -181,16 +181,16 @@ export default class DiagnosticGenerator extends Handler { private async reportWarningsForOpenFiles() { const openURIs = this.documents.keys(); const paths = - openURIs.map(uri => this.converter.getWorkspacePathToFile({uri})) + openURIs.map((uri) => this.converter.getWorkspacePathToFile({uri})) .filter( - path => - !this.fileGlobsToFilterOut.some(glob => glob.match(path))); + (path) => + !this.fileGlobsToFilterOut.some((glob) => glob.match(path))); const {warnings} = await this.linter.lint(paths); const diagnosticsByUri = new Map(openURIs.map((k): [string, Diagnostic[]] => [k, []])); for (const warning of this.filterWarnings(warnings)) { const diagnostic = this.converter.convertWarningToDiagnostic(warning); - let diagnostics = diagnosticsByUri.get(warning.sourceRange.file) || []; + const diagnostics = diagnosticsByUri.get(warning.sourceRange.file) || []; diagnostics.push(diagnostic); diagnosticsByUri.set(warning.sourceRange.file, diagnostics); } @@ -204,10 +204,10 @@ export default class DiagnosticGenerator extends Handler { private filterWarnings(warnings: ReadonlyArray): ReadonlyArray { return warnings.filter( - w => + (w) => !(this.warningCodesToFilterOut.has(w.code) || this.fileGlobsToFilterOut.some( - glob => glob.match(this.converter.getWorkspacePathToFile( + (glob) => glob.match(this.converter.getWorkspacePathToFile( {uri: w.sourceRange.file}))))); } diff --git a/packages/editor-service/src/language-server/feature-finder.ts b/packages/editor-service/src/language-server/feature-finder.ts index c33e4395a..f4550878b 100644 --- a/packages/editor-service/src/language-server/feature-finder.ts +++ b/packages/editor-service/src/language-server/feature-finder.ts @@ -104,7 +104,7 @@ export default class FeatureFinder { } const feature = concatMap(elements, (el) => el.attributes.values()) - .find(at => at.name === htmlLocation.attribute); + .find((at) => at.name === htmlLocation.attribute); if (feature) { return {document, feature}; } @@ -221,7 +221,7 @@ export class DatabindingFeature { } function concatMap(inputs: Iterable, f: (i: I) => Iterable): O[] { - let results: O[] = []; + const results: O[] = []; for (const input of inputs) { results.push(...f(input)); } diff --git a/packages/editor-service/src/language-server/file-synchronizer.ts b/packages/editor-service/src/language-server/file-synchronizer.ts index 427cb92f4..aaef8e7a2 100644 --- a/packages/editor-service/src/language-server/file-synchronizer.ts +++ b/packages/editor-service/src/language-server/file-synchronizer.ts @@ -81,7 +81,7 @@ export default class FileSynchronizer extends AutoDisposable { // in-memory buffers, so we filter them out to avoid sending duplicate // events for those changes. const diskBackedChanges = - req.changes.filter(ch => !inMemoryURIs.has(ch.uri)); + req.changes.filter((ch) => !inMemoryURIs.has(ch.uri)); fire(diskBackedChanges); }); } diff --git a/packages/editor-service/src/language-server/hover-documenter.ts b/packages/editor-service/src/language-server/hover-documenter.ts index c9eefc8a7..a9b253687 100644 --- a/packages/editor-service/src/language-server/hover-documenter.ts +++ b/packages/editor-service/src/language-server/hover-documenter.ts @@ -49,7 +49,7 @@ export default class HoverDocumenter extends Handler { if (!documentation) { return; } - let result: Hover = {contents: documentation.contents, range: undefined}; + const result: Hover = {contents: documentation.contents, range: undefined}; if (documentation.range) { result.range = this.converter.convertPRangeToL(documentation.range); } diff --git a/packages/editor-service/src/polymer-language-server.ts b/packages/editor-service/src/polymer-language-server.ts index cb61d8d3c..3af69bc6f 100644 --- a/packages/editor-service/src/polymer-language-server.ts +++ b/packages/editor-service/src/polymer-language-server.ts @@ -41,7 +41,7 @@ async function main(options: Options) { await import('./language-server/language-server'); // Create a connection for the server. Communicate using stdio. - let connection = createConnection(process.stdin, process.stdout); + const connection = createConnection(process.stdin, process.stdout); const serverPromise = LanguageServer.initializeWithConnection( connection, {interceptConsole: true, logToFile: options.logToFile}); diff --git a/packages/editor-service/src/test/analyzer-synchronizer_test.ts b/packages/editor-service/src/test/analyzer-synchronizer_test.ts index 5befe4a02..ece895ec8 100644 --- a/packages/editor-service/src/test/analyzer-synchronizer_test.ts +++ b/packages/editor-service/src/test/analyzer-synchronizer_test.ts @@ -28,19 +28,19 @@ suite('AnalyzerSynchronizer', function() { const {client, baseDir} = await createTestEnvironment(); await client.openFile('foo.html', ``); assert.deepEqual( - (await client.getNextDiagnostics('foo.html')).map(d => d.code), + (await client.getNextDiagnostics('foo.html')).map((d) => d.code), ['could-not-load']); writeFileSync(path.join(baseDir, 'bar.html'), '', 'utf-8'); await client.watchedFilesChanged( [{path: 'bar.html', type: FileChangeType.Created}]); assert.deepEqual( - (await client.getNextDiagnostics('foo.html')).map(d => d.code), []); + (await client.getNextDiagnostics('foo.html')).map((d) => d.code), []); unlinkSync(path.join(baseDir, 'bar.html')); await client.watchedFilesChanged( [{path: 'bar.html', type: FileChangeType.Deleted}]); assert.deepEqual( - (await client.getNextDiagnostics('foo.html')).map(d => d.code), + (await client.getNextDiagnostics('foo.html')).map((d) => d.code), ['could-not-load']); await client.cleanup(); }); @@ -50,14 +50,14 @@ suite('AnalyzerSynchronizer', function() { await client.openFile( 'foo.html', ``); assert.deepEqual( - (await client.getNextDiagnostics('foo.html')).map(d => d.code), + (await client.getNextDiagnostics('foo.html')).map((d) => d.code), ['could-not-load']); mkdirSync(path.join(baseDir, 'dir')); writeFileSync(path.join(baseDir, 'dir', 'bar.html'), '', 'utf-8'); await client.watchedFilesChanged( [{path: 'dir/bar.html', type: FileChangeType.Created}]); assert.deepEqual( - (await client.getNextDiagnostics('foo.html')).map(d => d.code), []); + (await client.getNextDiagnostics('foo.html')).map((d) => d.code), []); unlinkSync(path.join(baseDir, 'dir', 'bar.html')); rmdirSync(path.join(baseDir, 'dir')); @@ -65,7 +65,7 @@ suite('AnalyzerSynchronizer', function() { await client.watchedFilesChanged( [{path: 'dir', type: FileChangeType.Deleted}]); assert.deepEqual( - (await client.getNextDiagnostics('foo.html')).map(d => d.code), + (await client.getNextDiagnostics('foo.html')).map((d) => d.code), ['could-not-load']); await client.cleanup(); }); diff --git a/packages/editor-service/src/test/ast-from-source-position_test.ts b/packages/editor-service/src/test/ast-from-source-position_test.ts index 4822bc75f..4fd362ac3 100644 --- a/packages/editor-service/src/test/ast-from-source-position_test.ts +++ b/packages/editor-service/src/test/ast-from-source-position_test.ts @@ -150,7 +150,7 @@ suite('getLocationInfoForPosition', () => { }); test(`it can handle the contents of a template tag`, () => { - let allKindsSpaceSeparated = + const allKindsSpaceSeparated = getAllKindsSpaceSeparated(''); assert.match( allKindsSpaceSeparated, @@ -169,7 +169,7 @@ suite('getLocationInfoForPosition', () => { text, 'uninteresting file name.html' as ResolvedUrl, new PackageUrlResolver()); return getEveryPosition(text) - .map(pos => getHtmlAstLocationForPosition(doc, pos).kind) + .map((pos) => getHtmlAstLocationForPosition(doc, pos).kind) .join(' '); } }); diff --git a/packages/editor-service/src/test/auto-completer_test.ts b/packages/editor-service/src/test/auto-completer_test.ts index 0985b4e60..4844f2636 100644 --- a/packages/editor-service/src/test/auto-completer_test.ts +++ b/packages/editor-service/src/test/auto-completer_test.ts @@ -91,11 +91,11 @@ const elementCompletions: CompletionItem[] = [ ]; // Like elementCompletions, but without leading `<` characters. -const elementTagnameCompletions = elementCompletions.map(ec => { +const elementTagnameCompletions = elementCompletions.map((ec) => { return {...ec, insertText: ec.insertText!.slice(1)}; }); -const elementCompletionsWithPlainDescriptions = elementCompletions.map(ec => { +const elementCompletionsWithPlainDescriptions = elementCompletions.map((ec) => { return {...ec, documentation: (ec.documentation as MarkupContent).value}; }); @@ -339,7 +339,7 @@ suite('AutoCompleter', () => { }); // There's an invalid expression in this source file, but that's ok. assert.deepEqual( - (await client.getNextDiagnostics(testFile)).map(d => d.code), + (await client.getNextDiagnostics(testFile)).map((d) => d.code), ['invalid-polymer-expression']); await client.cleanup(); }); @@ -377,7 +377,7 @@ suite('AutoCompleter', () => { }); // There's an invalid expression in this source file, but that's ok. assert.deepEqual( - (await client.getNextDiagnostics(testFile)).map(d => d.code), + (await client.getNextDiagnostics(testFile)).map((d) => d.code), ['invalid-polymer-expression']); await client.cleanup(); }); @@ -417,7 +417,7 @@ suite('AutoCompleter', () => { }); // There's an invalid expression in this source file, but that's ok. assert.deepEqual( - (await client.getNextDiagnostics(testFile)).map(d => d.code), + (await client.getNextDiagnostics(testFile)).map((d) => d.code), ['invalid-polymer-expression']); await client.cleanup(); }); @@ -482,7 +482,7 @@ suite('AutoCompleter', () => { const {client} = await createTestEnvironment({fixtureDir}); await client.openFile(indexFile); assert.deepEqual( - (await client.getNextDiagnostics(indexFile)).map(d => d.code), []); + (await client.getNextDiagnostics(indexFile)).map((d) => d.code), []); // We load a file that contains a reference error. await client.changeFile(indexFile, `${indexContents} @@ -495,7 +495,7 @@ suite('AutoCompleter', () => { {isIncomplete: false, items: attributeCompletions}); assert.deepEqual( - (await client.getNextDiagnostics(indexFile)).map(d => d.code), + (await client.getNextDiagnostics(indexFile)).map((d) => d.code), ['could-not-load']); await client.cleanup(); }); @@ -518,15 +518,15 @@ suite('AutoCompleter', () => { // Consume diagnostics that are reported. assert.deepEqual( - (await client.getNextDiagnostics(indexFile)).map(d => d.code), + (await client.getNextDiagnostics(indexFile)).map((d) => d.code), ['could-not-load']); // We get this one twice, once when the file is opened, and again when // indexFile is modified. assert.deepEqual( - (await client.getNextDiagnostics('syntax-error.js')).map(d => d.code), + (await client.getNextDiagnostics('syntax-error.js')).map((d) => d.code), ['parse-error']); assert.deepEqual( - (await client.getNextDiagnostics('syntax-error.js')).map(d => d.code), + (await client.getNextDiagnostics('syntax-error.js')).map((d) => d.code), ['parse-error']); await client.cleanup(); }); diff --git a/packages/editor-service/src/test/definition-finder_test.ts b/packages/editor-service/src/test/definition-finder_test.ts index 67c992695..96a59695a 100644 --- a/packages/editor-service/src/test/definition-finder_test.ts +++ b/packages/editor-service/src/test/definition-finder_test.ts @@ -276,13 +276,13 @@ customElements.define('anonymous-class', class extends HTMLElement{}); await client.changeConfiguration({referencesCodeLens: false}); assert.deepEqual( - (await client.getCodeLenses('lib.html'))!.map(c => c.command!.title), + (await client.getCodeLenses('lib.html'))!.map((c) => c.command!.title), []); await client.changeConfiguration({referencesCodeLens: true}); assert.deepEqual( - (await client.getCodeLenses('lib.html'))!.map(c => c.command!.title), + (await client.getCodeLenses('lib.html'))!.map((c) => c.command!.title), [`Read 2 places.`, `Read 1 place.`, `Read 2 places.`]); await client.cleanup(); }); @@ -308,13 +308,13 @@ customElements.define('anonymous-class', class extends HTMLElement{}); await client.changeConfiguration({referencesCodeLens: false}); assert.deepEqual( - (await client.getCodeLenses('index.html'))!.map(c => c.command!.title), + (await client.getCodeLenses('index.html'))!.map((c) => c.command!.title), []); await client.changeConfiguration({referencesCodeLens: true}); assert.deepEqual( - (await client.getCodeLenses('index.html'))!.map(c => c.command!.title), + (await client.getCodeLenses('index.html'))!.map((c) => c.command!.title), [`Referenced 3 places in HTML.`, `Referenced 1 place in HTML.`]); await client.cleanup(); }); diff --git a/packages/editor-service/src/test/diagnostics_test.ts b/packages/editor-service/src/test/diagnostics_test.ts index 471b3ae56..9de542250 100644 --- a/packages/editor-service/src/test/diagnostics_test.ts +++ b/packages/editor-service/src/test/diagnostics_test.ts @@ -43,7 +43,7 @@ suite('DiagnosticGenerator', function() { const badImport = ``; const badContents = `${badImport}\n\n${indexContents}`; await client.openFile(indexPath, badContents); - let diagnostics = await client.getNextDiagnostics(indexPath); + const diagnostics = await client.getNextDiagnostics(indexPath); assert.containSubset( diagnostics, [{code: 'could-not-load', severity: DiagnosticSeverity.Error}]); @@ -184,7 +184,7 @@ suite('DiagnosticGenerator', function() { `); assert.deepEqual( - (await client.getNextDiagnostics('index.html')).map(d => d.code), + (await client.getNextDiagnostics('index.html')).map((d) => d.code), ['could-not-load', 'could-not-resolve-reference']); await client.openFile( @@ -192,7 +192,7 @@ suite('DiagnosticGenerator', function() { JSON.stringify({lint: {ignoreWarnings: ['could-not-load']}})); assert.deepEqual( - (await client.getNextDiagnostics('index.html')).map(d => d.code), + (await client.getNextDiagnostics('index.html')).map((d) => d.code), ['could-not-resolve-reference']); await client.cleanup(); @@ -212,7 +212,7 @@ suite('DiagnosticGenerator', function() { `); assert.deepEqual( - (await client.getNextDiagnostics('index.html')).map(d => d.code), + (await client.getNextDiagnostics('index.html')).map((d) => d.code), ['could-not-load', 'could-not-resolve-reference']); await client.openFile( @@ -220,7 +220,7 @@ suite('DiagnosticGenerator', function() { JSON.stringify({lint: {filesToIgnore: ['*dex*.html']}})); assert.deepEqual( - (await client.getNextDiagnostics('index.html')).map(d => d.code), []); + (await client.getNextDiagnostics('index.html')).map((d) => d.code), []); await client.cleanup(); }); @@ -234,19 +234,19 @@ suite('DiagnosticGenerator', function() { await client.watchedFilesChanged( [{path: 'polymer.json', type: FileChangeType.Created}]); assert.deepEqual( - (await client.getNextDiagnostics('polymer.json')).map(d => d.message), + (await client.getNextDiagnostics('polymer.json')).map((d) => d.message), [`Could not find lint rule with code 'bad'`]); await client.openFile( 'polymer.json', JSON.stringify({lint: {rules: ['polymer-2']}})); assert.deepEqual( - (await client.getNextDiagnostics('polymer.json')).map(d => d.message), + (await client.getNextDiagnostics('polymer.json')).map((d) => d.message), []); await client.changeFile( 'polymer.json', JSON.stringify({lint: {rules: {}}})); // This assertion is a bit roundabout because I have a PR out to improve // the warning generated by polymer project config. const messages = - (await client.getNextDiagnostics('polymer.json')).map(d => d.message); + (await client.getNextDiagnostics('polymer.json')).map((d) => d.message); assert.match( messages[0], /Invalid polymer\.json file.*not of.*type.*array/); await client.cleanup(); diff --git a/packages/editor-service/src/test/file-synchronizer_test.ts b/packages/editor-service/src/test/file-synchronizer_test.ts index d35caeded..654a0753b 100644 --- a/packages/editor-service/src/test/file-synchronizer_test.ts +++ b/packages/editor-service/src/test/file-synchronizer_test.ts @@ -44,7 +44,7 @@ suite('FileSynchronizer', () => { 'Filesystem content'); // Open the document - let openParams: DidOpenTextDocumentParams = { + const openParams: DidOpenTextDocumentParams = { textDocument: { languageId: 'html', text: 'Initial text document content', @@ -62,7 +62,7 @@ suite('FileSynchronizer', () => { 'Initial text document content'); // Change the file in memory - let changeParams: DidChangeTextDocumentParams = { + const changeParams: DidChangeTextDocumentParams = { textDocument: {uri: indexUri, version: 1}, contentChanges: [{ range: {start: {line: 0, character: 0}, end: {line: 0, character: 100}}, @@ -79,7 +79,7 @@ suite('FileSynchronizer', () => { 'Changed text document content'); // Close without saving - let closeParams: + const closeParams: DidCloseTextDocumentParams = {textDocument: {uri: indexUri}}; clientConnection.sendNotification( DidCloseTextDocumentNotification.type, closeParams); diff --git a/packages/editor-service/src/test/util.ts b/packages/editor-service/src/test/util.ts index 0cf31cf8c..dfbb3a49e 100644 --- a/packages/editor-service/src/test/util.ts +++ b/packages/editor-service/src/test/util.ts @@ -140,7 +140,7 @@ export class Underliner extends BaseUnderliner { Promise { const document = {uri: this.converter.getUriForLocalPath(path)}; return this.underline(diagnostics.map( - d => this.converter.convertLRangeToP(d.range, document))); + (d) => this.converter.convertLRangeToP(d.range, document))); } } @@ -201,7 +201,7 @@ export class TestClient { if (batch.length > 0) { throw new Error( `Found unconsumed diagnostics while cleaning up client. Path: ${path - } [${batch.map(d => d.code) + } [${batch.map((d) => d.code) .join(', ')}]`); } } diff --git a/packages/editor-service/tslint.json b/packages/editor-service/tslint.json index 23598c6bb..40a18cdec 100644 --- a/packages/editor-service/tslint.json +++ b/packages/editor-service/tslint.json @@ -1,58 +1,3 @@ { - "rules": { - "class-name": true, - "indent": [ - true, - "spaces" - ], - "no-duplicate-variable": true, - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "semicolon": [ - true, - "always" - ], - "trailing-comma": [ - true, - "multiline" - ], - "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" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } + "extends": "../../tslint.json" } diff --git a/packages/linter/src/polymer/elements/iron-form-v1-to-v2.ts b/packages/linter/src/polymer/elements/iron-form-v1-to-v2.ts index 5477f71f3..78a3311a3 100644 --- a/packages/linter/src/polymer/elements/iron-form-v1-to-v2.ts +++ b/packages/linter/src/polymer/elements/iron-form-v1-to-v2.ts @@ -50,7 +50,7 @@ const propertiesToRename: ReadonlyMap = new Map([ class IronFormV1ToV2 extends HtmlRule { code = 'iron-form-v1-to-v2'; description = stripIndentation(` - Warns when \`iron-form\` is used as type extension. + Warns when \`iron-form\` is used as type extension. This: diff --git a/packages/linter/src/util.ts b/packages/linter/src/util.ts index dcb478e21..95a4dc9b8 100644 --- a/packages/linter/src/util.ts +++ b/packages/linter/src/util.ts @@ -32,7 +32,7 @@ import stripIndent = require('strip-indent'); */ export function stripWhitespace(str: string) { return str.trim().replace(/\s*\n\s*/g, ' '); -}; +} /** * A utility for writing long multiline strings inline in code. diff --git a/packages/linter/tslint.json b/packages/linter/tslint.json index 62845b0da..40a18cdec 100644 --- a/packages/linter/tslint.json +++ b/packages/linter/tslint.json @@ -1,5 +1,3 @@ { - "extends": [ - "@polymer/tools-common/tslint.json" - ] + "extends": "../../tslint.json" } diff --git a/packages/polyserve/src/start_server.ts b/packages/polyserve/src/start_server.ts index 2df83aa51..d7b955baa 100644 --- a/packages/polyserve/src/start_server.ts +++ b/packages/polyserve/src/start_server.ts @@ -238,11 +238,11 @@ async function findVariants(options: ServerOptions) { const root = options.root || process.cwd(); const filesInRoot = await fs.readdir(root); const variants = filesInRoot - .map(f => { + .map((f) => { const match = f.match(`^${options.componentDir}-(.*)`); return match && {name: match[1], directory: match[0]}; }) - .filter(f => f != null && f.name !== ''); + .filter((f) => f != null && f.name !== ''); return variants; } @@ -274,7 +274,7 @@ async function startVariants( app: variantServer.app, options: variantOpts }); - }; + } const controlServerInfo = await startControlServer(options, mainServerInfo, variantServerInfos); @@ -289,7 +289,7 @@ async function startVariants( servers, }; return result; -}; +} export async function startControlServer( options: ServerOptions, @@ -304,7 +304,7 @@ export async function startControlServer( mainlineServer: { port: mainlineInfo.server.address().port, }, - variants: variantInfos.map(info => { + variants: variantInfos.map((info) => { return {name: info.variantName, port: info.server.address().port}; }) })); @@ -364,7 +364,7 @@ export function getApp(options: ServerOptions): express.Express { let escapedPath = options.proxy.path; - for (let char of ['*', '?', '+']) { + for (const char of ['*', '?', '+']) { if (escapedPath.indexOf(char) > -1) { console.warn( `Proxy path includes character "${char}"` + diff --git a/packages/polyserve/src/test/cli_test.ts b/packages/polyserve/src/test/cli_test.ts index fc761226d..78b5518fa 100644 --- a/packages/polyserve/src/test/cli_test.ts +++ b/packages/polyserve/src/test/cli_test.ts @@ -36,7 +36,7 @@ suite('cli', () => { const originalArgv = process.argv; process.argv = ['node', 'polyserve'].concat(args); let stdout = ''; - let unintercept = intercept((txt) => { + const unintercept = intercept((txt) => { stdout += txt; return ''; }); diff --git a/packages/polyserve/src/test/make_app_test.ts b/packages/polyserve/src/test/make_app_test.ts index ba1c6f399..d2023e198 100644 --- a/packages/polyserve/src/test/make_app_test.ts +++ b/packages/polyserve/src/test/make_app_test.ts @@ -25,27 +25,27 @@ const packageName = 'polyserve-test'; suite('makeApp', () => { test('returns an app', () => { - let app = makeApp({root, componentDir, packageName}); + const app = makeApp({root, componentDir, packageName}); assert.isOk(app); assert.equal(app.packageName, 'polyserve-test'); }); test('serves package files', async () => { - let app = makeApp({root, componentDir, packageName}); + const app = makeApp({root, componentDir, packageName}); await supertest(app) .get('/polyserve-test/test-file.txt') .expect(200, 'PASS\n'); }); test('supports relative roots', async () => { - let app = makeApp({root: './test', componentDir, packageName}); + const app = makeApp({root: './test', componentDir, packageName}); await supertest(app) .get('/polyserve-test/test-file.txt') .expect(200, 'PASS\n'); }); test('serves component files', async () => { - let app = makeApp({ + const app = makeApp({ root, componentDir: path.join(root, 'bower_components'), packageName, @@ -56,7 +56,7 @@ suite('makeApp', () => { }); test('serves component indices', async () => { - let app = makeApp({ + const app = makeApp({ root, componentDir: path.join(root, 'bower_components'), packageName, @@ -65,7 +65,7 @@ suite('makeApp', () => { }); test('redirects directories without trailing slashes', async () => { - let app = makeApp({ + const app = makeApp({ root, componentDir: path.join(root, 'bower_components'), packageName, @@ -77,7 +77,7 @@ suite('makeApp', () => { }); test('serves scoped package files', async () => { - let app = makeApp({ + const app = makeApp({ root, componentDir, packageName: '@polymer/polyserve-test', @@ -88,7 +88,7 @@ suite('makeApp', () => { }); test('serves scoped component files', async () => { - let app = makeApp({ + const app = makeApp({ root, componentDir: path.join(root, 'npm-package/node_modules'), packageName: '@polymer/polyserve-test', diff --git a/packages/polyserve/src/test/start_server_test.ts b/packages/polyserve/src/test/start_server_test.ts index d00d25cc1..9cf46cbb4 100644 --- a/packages/polyserve/src/test/start_server_test.ts +++ b/packages/polyserve/src/test/start_server_test.ts @@ -366,9 +366,9 @@ suite('startServer', () => { await sinon.assert.calledOnce(createCertSpy); await Promise.all([ fs.readFile(certFilePath) - .then(buf => _assertValidCert(buf.toString())), + .then((buf) => _assertValidCert(buf.toString())), fs.readFile(keyFilePath) - .then(buf => _assertValidKey(buf.toString())) + .then((buf) => _assertValidKey(buf.toString())) ]); await _deleteFiles([certFilePath, keyFilePath]); await new Promise((resolve) => server.close(resolve)); @@ -388,9 +388,9 @@ suite('startServer', () => { // _certFile and _keyFile point to newly created (blank) temp // files fs.readFile(_certFile.name) - .then(buf => _assertValidCert(buf.toString())), + .then((buf) => _assertValidCert(buf.toString())), fs.readFile(_keyFile.name) - .then(buf => _assertValidKey(buf.toString())) + .then((buf) => _assertValidKey(buf.toString())) ]); await new Promise((resolve) => server.close(resolve)); } finally { @@ -486,7 +486,7 @@ suite('startServer', () => { } async function _startStubServer(options: ServerOptions) { - return new Promise(resolve => { + return new Promise((resolve) => { _stubServer.listen = (() => resolve(_stubServer)) as any; startServer(options); }); @@ -585,12 +585,12 @@ suite('startServers', () => { .get('/components/contents.txt') .expect(200, 'mainline\n'); - const fooServer = servers.variants.find(s => s.variantName === 'foo'); + const fooServer = servers.variants.find((s) => s.variantName === 'foo'); await supertest(fooServer.server) .get('/components/contents.txt') .expect(200, 'foo\n'); - const barServer = servers.variants.find(s => s.variantName === 'bar'); + const barServer = servers.variants.find((s) => s.variantName === 'bar'); await supertest(barServer.server) .get('/components/contents.txt') .expect(200, 'bar\n'); @@ -639,12 +639,12 @@ suite('startServers', () => { .get('/components/contents.txt') .expect(200, 'my-mainline\n'); - const fooServer = servers.variants.find(s => s.variantName === 'foo'); + const fooServer = servers.variants.find((s) => s.variantName === 'foo'); await supertest(fooServer.server) .get('/components/contents.txt') .expect(200, 'my-foo\n'); - const barServer = servers.variants.find(s => s.variantName === 'bar'); + const barServer = servers.variants.find((s) => s.variantName === 'bar'); await supertest(barServer.server) .get('/components/contents.txt') .expect(200, 'my-bar\n'); diff --git a/packages/polyserve/src/util/push.ts b/packages/polyserve/src/util/push.ts index 61a695e8e..9d17a0231 100644 --- a/packages/polyserve/src/util/push.ts +++ b/packages/polyserve/src/util/push.ts @@ -21,7 +21,7 @@ import {ServerOptions} from '../start_server'; /** h2 push manifest cache */ -let _pushManifest = {}; +const _pushManifest = {}; /** * Asserts file existence for all specified files in a push-manifest diff --git a/packages/polyserve/src/util/tls.ts b/packages/polyserve/src/util/tls.ts index 54f5865de..e9090de0c 100644 --- a/packages/polyserve/src/util/tls.ts +++ b/packages/polyserve/src/util/tls.ts @@ -54,7 +54,7 @@ async function _readKeyAndCert( try { const results = (await Promise.all([fs.readFile(certPath), fs.readFile(keyPath)])) - .map(buffer => buffer.toString().trim()); + .map((buffer) => buffer.toString().trim()); const cert = results[0]; const key = results[1]; if (key && cert) { diff --git a/packages/polyserve/tslint.json b/packages/polyserve/tslint.json index 23598c6bb..40a18cdec 100644 --- a/packages/polyserve/tslint.json +++ b/packages/polyserve/tslint.json @@ -1,58 +1,3 @@ { - "rules": { - "class-name": true, - "indent": [ - true, - "spaces" - ], - "no-duplicate-variable": true, - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "semicolon": [ - true, - "always" - ], - "trailing-comma": [ - true, - "multiline" - ], - "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" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } + "extends": "../../tslint.json" } diff --git a/packages/project-config/src/index.ts b/packages/project-config/src/index.ts index b7f84dde7..8697b1e29 100644 --- a/packages/project-config/src/index.ts +++ b/packages/project-config/src/index.ts @@ -546,7 +546,7 @@ export class ProjectConfig { lintObj = {...this.lint}; delete lintObj.ignoreWarnings; } - const isWindows = process.platform === "win32"; + const isWindows = process.platform === 'win32'; const normalizePath = isWindows ? (path: string) => path.replace(/\\/g, '/') : (path: string) => path; const obj = { entrypoint: globRelative(this.root, this.entrypoint), @@ -583,7 +583,7 @@ const getSchema: () => jsonschema.Schema = (() => { fs.readFileSync(path.join(__dirname, 'schema.json'), 'utf-8')); } return schema; - } + }; })(); diff --git a/packages/project-config/tslint.json b/packages/project-config/tslint.json new file mode 100644 index 000000000..0946f2096 --- /dev/null +++ b/packages/project-config/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tslint.json" +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 000000000..84f54ee5c --- /dev/null +++ b/tslint.json @@ -0,0 +1,60 @@ +{ + "rules": { + "arrow-parens": true, + "class-name": true, + "indent": [ + true, + "spaces" + ], + "prefer-const": true, + "no-duplicate-variable": true, + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "semicolon": [ + true, + "always" + ], + "trailing-comma": [ + true, + "multiline" + ], + "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" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +}