Skip to content

Commit

Permalink
Merge pull request #166 from Polymer/shared-tslint
Browse files Browse the repository at this point in the history
Use a single shared top-level tslint
  • Loading branch information
rictic authored Apr 18, 2018
2 parents 8b1fa25 + e24cc62 commit dfdceb0
Show file tree
Hide file tree
Showing 70 changed files with 227 additions and 445 deletions.
2 changes: 1 addition & 1 deletion packages/analyzer/src/core/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Scanner<ParsedDocument, {}, {}>[]>;
export type LazyEdgeMap = Map<ResolvedUrl, PackageRelativeUrl[]>;
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/css/css-custom-property-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ function* findAllMatchesInString(regex: RegExp, haystack: string) {
while (match = regex.exec(haystack)) {
yield {offset: match.index, matched: match[0]};
}
};
}
2 changes: 1 addition & 1 deletion packages/analyzer/src/demo/polymer-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function main() {
if (worstSeverity === Severity.ERROR) {
process.exit(1);
}
};
}

async function getWarnings(
analyzer: Analyzer, localPath: string): Promise<Warning[]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/javascript/function-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions packages/analyzer/src/javascript/resolve-specifier-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/json/json-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ParsedJsonDocument extends ParsedDocument<Json, Visitor> {
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);
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/model/inline-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface HtmlAstNode {
node: dom5.Node;
containingDocument: ParsedHtmlDocument;
}
;


export interface JsAstNode<N extends babel.Node = babel.Node> {
language: 'js';
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/perf/parse-all-benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function measure() {
`\n==========================================\n\n`);
process.exit(1);
}
};
}

function printMeasurements(measurements: number[]) {
console.log(`\n\n\n\n
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/polymer/analyze-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ export function analyzeProperties(
analyzedProps.push(prop);
}
return analyzedProps;
};
}
2 changes: 1 addition & 1 deletion packages/analyzer/src/polymer/js-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ export function toScannedPolymerProperty(
};

return result;
};
}
4 changes: 2 additions & 2 deletions packages/analyzer/src/scanning/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ scan<AstNode, Visitor, PDoc extends ParsedDocument<AstNode, Visitor>>(
// Let `scan` continue after calls to visit().then()
currentDoneCallback();
}
};
}

// The callback passed to `scan()`
function visit(visitor: Visitor) {
Expand All @@ -81,7 +81,7 @@ scan<AstNode, Visitor, PDoc extends ParsedDocument<AstNode, Visitor>>(
});
}
return visitorsPromise;
};
}

// Ok, go!
setup();
Expand Down
4 changes: 2 additions & 2 deletions packages/analyzer/src/test/core/analyzer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1366,4 +1366,4 @@ var DuplicateNamespace = {};

async function getContext(analyzer: Analyzer) {
return await analyzer['_analysisComplete'];
};
}
2 changes: 1 addition & 1 deletion packages/analyzer/src/test/core/dependency-graph_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
8 changes: 4 additions & 4 deletions packages/analyzer/src/test/javascript/class-scanner_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScannedClass[]> {
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 = {
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ suite('FunctionScanner', async () => {
}
}
return scannedFunctions;
};
}


async function getTestProps(fn: ScannedFunction): Promise<any> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ suite('NamespaceScanner', async () => {
}
}
return scannedNamespaces;
};
}

function getProperties(namespace: ScannedNamespace) {
return [...namespace.properties.values()].map((prop) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/test/model/warning_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ suite('applyEdits', () => {
},
replacementText
};
};
}

test('works in the trivial case', async () => {
const contents = 'abc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/src/test/polymer/polymer-element_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
const props: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ suite('Polymer2ElementScanner', async () => {

return features.filter((e) => e instanceof ScannedPolymerElement) as
ScannedPolymerElement[];
};
}

async function getTestProps(element: ScannedPolymerElement): Promise<any> {
const props: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ suite('Polymer2MixinScanner with old jsdoc annotations', async () => {
const {features} = await runScanner(analyzer, new ClassScanner(), filename);
return <ScannedPolymerElementMixin[]>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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ suite('Polymer2MixinScanner', async () => {
const {features} = await runScanner(analyzer, new ClassScanner(), filename);
return <ScannedPolymerElementMixin[]>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) {
Expand Down
59 changes: 1 addition & 58 deletions packages/analyzer/tslint.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion packages/browser-capabilities/src/browser-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function browserCapabilities(userAgent: string): Set<BrowserCapability> {
if (predicates[capability](ua)) {
capabilities.add(capability);
}
};
}
return capabilities;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/browser-capabilities/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tslint.json"
}
2 changes: 1 addition & 1 deletion packages/build/src/html-splitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit dfdceb0

Please sign in to comment.