Commit 6fcb0985 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[clean] Applied formatter and added format enforcement on build

parent 8919b430fc88
......@@ -18,7 +18,6 @@ echo "=========================================="
(cd "$ROOT/libview"; rm -rf build)
(cd "$ROOT/libview"; npm install)
(cd "$ROOT/libview"; npm run build)
(cd "$ROOT/libview"; npm run linter)
(cd "$ROOT/libview"; npm run test)
echo ""
......@@ -29,7 +28,6 @@ echo "=========================================="
(cd "$ROOT/views-logilab"; rm -rf node_modules/@logilab/libview)
(cd "$ROOT/views-logilab"; npm install)
(cd "$ROOT/views-logilab"; npm run build)
(cd "$ROOT/views-logilab"; npm run linter)
(cd "$ROOT/views-logilab"; npm run test)
echo ""
......@@ -40,7 +38,6 @@ echo "=========================================="
(cd "$ROOT/extension"; rm -rf node_modules/@logilab/libview)
(cd "$ROOT/extension"; npm install)
(cd "$ROOT/extension"; npm run build)
(cd "$ROOT/extension"; npm run linter)
(cd "$ROOT/extension"; npm run test)
echo ""
......
......@@ -3,12 +3,12 @@
"version": "0.4.1",
"description": "A browser for the web of data.",
"scripts": {
"build": "webpack",
"clean": "rm -rf build/*",
"clean": "rm -rf build",
"format": "tsfmt -r",
"build": "tsfmt --verify && tslint -p . -c tslint.json 'src/**/*.ts*' && webpack",
"build:production": "NODE_ENV=production tsfmt --verify && tslint -p . -c tslint.json 'src/**/*.ts*' && webpack",
"test": "mocha --reporter spec --require ts-node/register src/**/*.test.ts",
"linter": "tslint -p . -c tslint.json 'src/**/*.ts*' --fix",
"webpack": "webpack -w",
"webpack:production": "NODE_ENV=production webpack"
"linter": "tslint -p . -c tslint.json 'src/**/*.ts*' --fix"
},
"repository": {
"type": "hg",
......@@ -45,6 +45,7 @@
"tslint": "^5.11.0",
"ts-node": "^7.0.1",
"typescript": "^2.9.2",
"typescript-formatter": "^7.2.2",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.0.0"
......
......@@ -430,8 +430,8 @@ chrome.pageAction.onClicked.addListener((tab: chrome.tabs.Tab) => {
let url = isNegotiated
? observation.url
: chrome.extension.getURL(
"ldbrowser/index.html?target=" + encodeURIComponent(observation.url)
);
"ldbrowser/index.html?target=" + encodeURIComponent(observation.url)
);
openingObservations = JSON.parse(JSON.stringify(observation));
if (openingObservations === null) return;
openingObservations.status = DocumentStatus.active;
......
......@@ -249,9 +249,9 @@ class LDBrowserImpl implements LDBrowser {
origin
? origin
: {
kind: OriginKind.Redirected,
url: uri
}
kind: OriginKind.Redirected,
url: uri
}
)
);
})
......@@ -474,7 +474,8 @@ class LDBrowserImpl implements LDBrowser {
});
}
};
resources.forEach(async(resource: application.Resource) => {
// tslint:disable-next-line:space-before-function-paren
resources.forEach(async (resource: application.Resource) => {
let childResource = await self.resolveResourceData(resource);
let childStore = await self.resolveRdfStore(childResource);
childStore.statements.forEach((statement: $rdf.Statement) => {
......@@ -540,7 +541,7 @@ class LDBrowserImpl implements LDBrowser {
{ uri: uri },
uri,
chrome.extension.getURL("ldbrowser/index.html?target=") +
encodeURIComponent(uri)
encodeURIComponent(uri)
);
this.onReachedUri(uri)
.then((value: void) => {
......
......@@ -39,7 +39,7 @@ export interface ConfigSourcesTabProps {
export class ConfigSourcesTab extends React.Component<
ConfigSourcesTabProps,
State
> {
> {
state: State;
constructor(props: ConfigSourcesTabProps) {
......@@ -83,8 +83,8 @@ export class ConfigSourcesTab extends React.Component<
</a>
</div>
) : (
<span />
)}
<span />
)}
<div className="col-2">
<a
className="btn btn-outline-light"
......@@ -169,8 +169,8 @@ export class ConfigSourcesTab extends React.Component<
</span>
</a>
) : (
<span />
)}
<span />
)}
</div>
<div className="col-10">
<span>{source.name}</span>
......@@ -179,15 +179,18 @@ export class ConfigSourcesTab extends React.Component<
{" : "}
<a
href={
// tslint:disable-next-line:no-unnecessary-type-assertion
(source as definition.ViewRegistrySourceRemote).uri
}
>
{(source as definition.ViewRegistrySourceRemote).uri}
{
// tslint:disable-next-line:no-unnecessary-type-assertion
(source as definition.ViewRegistrySourceRemote).uri}
</a>
</span>
) : (
<span />
)}
<span />
)}
</div>
</div>
);
......
......@@ -40,7 +40,7 @@ export interface CurrentTabComplianceProps {
export class CurrentTabCompliance extends React.Component<
CurrentTabComplianceProps,
{}
> {
> {
constructor(props: CurrentTabComplianceProps) {
super(props);
}
......@@ -128,8 +128,8 @@ export class CurrentTabCompliance extends React.Component<
<div className="col-6" />
</div>
) : (
<div />
)}
<div />
)}
<div className="row">
<div className="col-12">
<span style={{ fontSize: "17pt" }}>Linked Data Compliance</span>
......@@ -139,18 +139,18 @@ export class CurrentTabCompliance extends React.Component<
{warnings.length === 0 ? (
<span style={{ color: "darkgreen" }}>All is good!</span>
) : (
warnings.map((warning: ComplianceWarning, index: number) => {
return (
<div
className="row"
key={"warning-" + index}
style={{ marginTop: "5pt" }}
>
<div className="col-12">{this.renderWarning(warning)}</div>
</div>
);
})
)}
warnings.map((warning: ComplianceWarning, index: number) => {
return (
<div
className="row"
key={"warning-" + index}
style={{ marginTop: "5pt" }}
>
<div className="col-12">{this.renderWarning(warning)}</div>
</div>
);
})
)}
</div>
);
}
......
......@@ -41,7 +41,7 @@ export interface CurrentTabConfigProps {
export class CurrentTabConfig extends React.Component<
CurrentTabConfigProps,
{}
> {
> {
constructor(props: CurrentTabConfigProps) {
super(props);
}
......@@ -156,8 +156,8 @@ export class CurrentTabConfig extends React.Component<
</a>
</div>
) : (
<div />
)}
<div />
)}
<div>
{topic.uris.map((uri: string, index: number) => (
<div key={"topic-" + index}>
......@@ -254,8 +254,8 @@ export class CurrentTabConfig extends React.Component<
)
)
) : (
<span />
)}
<span />
)}
</span>
</div>
</div>
......
......@@ -36,7 +36,7 @@ export interface CurrentTabDataSourcesProps {
export class CurrentTabDataSources extends React.Component<
CurrentTabDataSourcesProps,
{}
> {
> {
constructor(props: CurrentTabDataSourcesProps) {
super(props);
}
......@@ -146,8 +146,8 @@ export class CurrentTabDataSources extends React.Component<
<div className="col-6" />
</div>
) : (
<div />
)}
<div />
)}
<div className="row">
<div className="col-12">
<span style={{ fontSize: "17pt" }}>Data sources</span>
......
......@@ -44,39 +44,39 @@ export class CurrentTabMenu extends React.Component<CurrentTabMenuProps, {}> {
{this.props.data.rendering === null
? null
: this.props.data.rendering.evaluations.map(
(evaluation: application.RenderingEvaluation, index: number) => {
let view = this.props.registry.descriptors[evaluation.viewId];
if (this.props.data.rendering === null || view === undefined) {
return null;
}
let isSelected =
this.props.data.rendering.viewId === evaluation.viewId;
return (
<div key={"evaluation-" + index} className="row">
<div className="col-2">
{isSelected ? (
<span style={{ color: "darkgreen" }}>&#x2713;</span>
) : (
(evaluation: application.RenderingEvaluation, index: number) => {
let view = this.props.registry.descriptors[evaluation.viewId];
if (this.props.data.rendering === null || view === undefined) {
return null;
}
let isSelected =
this.props.data.rendering.viewId === evaluation.viewId;
return (
<div key={"evaluation-" + index} className="row">
<div className="col-2">
{isSelected ? (
<span style={{ color: "darkgreen" }}>&#x2713;</span>
) : (
<span />
)}
</div>
<div className="col-10">
<a
className="btn btn-outline-light"
onClick={() =>
this.props.onSelectView(
view === undefined ? "" : view.identifier
)
}
title={view.identifier}
>
{view.name}
</a>
</div>
</div>
);
}
)}
<div className="col-10">
<a
className="btn btn-outline-light"
onClick={() =>
this.props.onSelectView(
view === undefined ? "" : view.identifier
)
}
title={view.identifier}
>
{view.name}
</a>
</div>
</div>
);
}
)}
<hr />
<div className="row">
<div className="col-12">
......
......@@ -31,7 +31,7 @@ export interface CurrentTabResourcesProps {
export class CurrentTabResources extends React.Component<
CurrentTabResourcesProps,
{}
> {
> {
constructor(props: CurrentTabResourcesProps) {
super(props);
}
......@@ -57,8 +57,8 @@ export class CurrentTabResources extends React.Component<
<div className="col-6" />
</div>
) : (
<div />
)}
<div />
)}
<div className="row">
<div className="col-12">
<span style={{ fontSize: "17pt" }}>Supplementary resources</span>
......
......@@ -55,8 +55,8 @@ export class CurrentTabViews extends React.Component<CurrentTabViewsProps, {}> {
<div className="col-6" />
</div>
) : (
<div />
)}
<div />
)}
<div className="row">
<div className="col-12">
<span style={{ fontSize: "17pt" }}>Evaluated views</span>
......@@ -66,27 +66,27 @@ export class CurrentTabViews extends React.Component<CurrentTabViewsProps, {}> {
{this.props.data.rendering === null ? (
<span />
) : (
this.props.data.rendering.evaluations.map(
(evaluation: application.RenderingEvaluation, index: number) => {
let view = this.props.registry.descriptors[evaluation.viewId];
if (view === undefined) return null;
return (
<div key={"evaluation-" + index} className="row">
<div className="col-12">
<span
title="Priority for this view"
className="badge badge-primary"
style={{ marginRight: "5pt" }}
>
{evaluation.priority}
</span>
<span>{view.name}</span>
this.props.data.rendering.evaluations.map(
(evaluation: application.RenderingEvaluation, index: number) => {
let view = this.props.registry.descriptors[evaluation.viewId];
if (view === undefined) return null;
return (
<div key={"evaluation-" + index} className="row">
<div className="col-12">
<span
title="Priority for this view"
className="badge badge-primary"
style={{ marginRight: "5pt" }}
>
{evaluation.priority}
</span>
<span>{view.name}</span>
</div>
</div>
</div>
);
}
)
)}
);
}
)
)}
<hr />
{Object.keys(this.props.registry.descriptors)
.map((viewId: string, index: number) => {
......
......@@ -109,7 +109,7 @@ export function refersToPrimaryTopic(link: Link): boolean {
return (
(link.tags.hasOwnProperty("rev") &&
"describedBy".toLocaleLowerCase() ===
link.tags.rev.toLocaleLowerCase()) ||
link.tags.rev.toLocaleLowerCase()) ||
(link.tags.hasOwnProperty("rel") && link.tags.rel === "bookmark")
);
}
......@@ -693,18 +693,18 @@ export function observeContent(
let source =
observable.content.length > 0 && mimeInfo !== undefined
? new DocumentSourceInline(
observable.url,
mimeInfo,
observable.content,
origin
)
observable.url,
mimeInfo,
observable.content,
origin
)
: new DocumentSourceLinked(
new Link(observable.url, [
{ name: "rel", value: "alternate" },
{ name: "type", value: observable.contentType }
]),
origin
);
new Link(observable.url, [
{ name: "rel", value: "alternate" },
{ name: "type", value: observable.contentType }
]),
origin
);
let observations: DocumentObservations = {
origin: origin,
primaryTopic: primary,
......
......@@ -26,7 +26,6 @@ import {
} from "./data";
import { definition } from "@logilab/libview";
import "chrome";
import { ViewRegistry } from "@logilab/libview/build/lib/view-def";
/**
* A message between parts of the extension
......
......@@ -169,8 +169,8 @@ function renderRdfNode(
nodeLiteral.lang.length > 0
? nodeLiteral.lang
: nodeLiteral.language.length > 0
? nodeLiteral.language
: "";
? nodeLiteral.language
: "";
let text = '"' + nodeLiteral.value + '"';
if (language.length > 0) text += "@" + language;
sub.appendChild(document.createTextNode(text));
......
......@@ -24,7 +24,6 @@ import { definition } from "@logilab/libview";
import {
getViewRegistry,
getCurrentResource,
Message,
getObservationsFor
} from "../common/messages";
import {
......
{
"baseIndentSize": 0,
"indentSize": 2,
"tabSize": 2,
"indentStyle": 2,
"newLineCharacter": "\n",
"convertTabsToSpaces": true,
"insertSpaceAfterCommaDelimiter": true,
"insertSpaceAfterSemicolonInForStatements": true,
"insertSpaceBeforeAndAfterBinaryOperators": true,
"insertSpaceAfterConstructor": false,
"insertSpaceAfterKeywordsInControlFlowStatements": true,
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"insertSpaceAfterTypeAssertion": false,
"insertSpaceBeforeFunctionParenthesis": false,
"insertSpaceBeforeTypeAnnotation": false,
"placeOpenBraceOnNewLineForFunctions": false,
"placeOpenBraceOnNewLineForControlBlocks": false
}
......@@ -36,6 +36,7 @@
"allow-fast-null-checks",
"allow-tagged-template"
],
"no-unused-variable": [true, { "ignore-pattern": "^_" }],
"no-var-keyword": true,
"radix": true,
"space-within-parens": [true, 0],
......
......@@ -3,11 +3,12 @@
"version": "0.4.0",
"description": "Library for view specification and definition for a data browser.",
"scripts": {
"build": "webpack",
"clean": "rm -rf build/*",
"clean": "rm -rf build",
"format": "tsfmt -r",
"build": "tsfmt --verify && tslint -p . -c tslint.json 'src/**/*.ts*' && webpack",
"build:production": "NODE_ENV=production tsfmt --verify && tslint -p . -c tslint.json 'src/**/*.ts*' && webpack",
"test": "mocha --reporter spec --require ts-node/register src/**/*.test.ts",
"linter": "tslint -p . -c tslint.json 'src/**/*.ts' --fix",
"build:production": "NODE_ENV=production webpack"
"linter": "tslint -p . -c tslint.json 'src/**/*.ts*' --fix"
},
"main": "./build/index.js",
"types": "./build/lib/index.d.ts",
......@@ -34,6 +35,7 @@
"ts-loader": "^4.4.2",
"ts-node": "^7.0.1",
"typescript": "^2.9.2",
"typescript-formatter": "^7.2.2",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1"
}
......
......@@ -222,9 +222,9 @@ function loadDescriptors(
.catch((reason: string) => {
console.log(
"Failed to fetch descriptor from source " +
source.name +
": " +
reason
source.name +
": " +
reason
);
onPartFinished();
});
......
......@@ -119,14 +119,15 @@ function fetchImplementation(
) => {
resolver(descriptor.resourceMain)
.then((content: string) => {
// tslint:disable-next-line:no-unused-variable
let EMBEDDED = IMPL_EMBEDDED;
try {
let result = eval(content);
if (result === null || result === undefined) {
reject(
"Failed to load definition of " +
descriptor.name +
": Cannot find entrypoint"
descriptor.name +
": Cannot find entrypoint"
);
return;
}
......@@ -136,8 +137,8 @@ function fetchImplementation(
if (result === null || result === undefined) {
reject(
"Failed to load definition of " +
descriptor.name +
": Cannot find entrypoint"
descriptor.name +
": Cannot find entrypoint"
);
} else {
resolve(result);
......@@ -149,8 +150,8 @@ function fetchImplementation(
.catch((reason: string) => {
reject(
"Failed to fetch definition of " +
descriptor.name +
": Cannot find entrypoint"
descriptor.name +
": Cannot find entrypoint"
);
});
}
......@@ -328,9 +329,9 @@ class ViewRendererImpl implements CachingViewRenderer {
.catch((reason: string) => {
console.log(
"Failed to fetch implementation for view " +
descriptor.name +
": " +
reason
descriptor.name +
": " +
reason
);
onPartFinished();
});
......