Skip to content

Commit 8ce6c13

Browse files
SplaktarSanderElias
authored andcommitted
fix(scully): lint issues and typos (#77)
- remove some unused imports - shorten some import paths - fix variables with the same name in the same scope
1 parent 02059cd commit 8ce6c13

17 files changed

Lines changed: 61 additions & 80 deletions

package-lock.json

Lines changed: 13 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"puppeteer": "^2.0.0",
8888
"ts-node": "^8.3.0",
8989
"tsickle": "^0.37.1",
90-
"tslint": "~5.18.0",
90+
"tslint": "~5.20.1",
9191
"typescript": "^3.6.4",
9292
"yargs": "^14.2.0"
9393
},

projects/sampleBlog/e2e/protractor.conf.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
// Protractor configuration file, see link for more information
33
// https://github.com/angular/protractor/blob/master/lib/config.ts
44

5-
const { SpecReporter } = require('jasmine-spec-reporter');
5+
const { SpecReporter } = require("jasmine-spec-reporter");
66

77
/**
88
* @type { import("protractor").Config }
99
*/
1010
exports.config = {
1111
allScriptsTimeout: 11000,
1212
specs: [
13-
'./src/**/*.e2e-spec.ts'
13+
"./src/**/*.e2e-spec.ts",
1414
],
1515
capabilities: {
16-
browserName: 'chrome'
16+
browserName: "chrome",
1717
},
1818
directConnect: true,
19-
baseUrl: 'http://localhost:4200/',
20-
framework: 'jasmine',
19+
baseUrl: "http://localhost:4200/",
20+
framework: "jasmine",
2121
jasmineNodeOpts: {
2222
showColors: true,
2323
defaultTimeoutInterval: 30000,
24-
print: function() {}
24+
print: function() {},
2525
},
2626
onPrepare() {
27-
require('ts-node').register({
28-
project: require('path').join(__dirname, './tsconfig.json')
27+
require("ts-node").register({
28+
project: require("path").join(__dirname, "./tsconfig.json"),
2929
});
3030
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
31-
}
32-
};
31+
},
32+
};

projects/scullyio/ng-lib/src/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export * from './lib/components.module';
66
export * from './lib/idleMonitor/idle-monitor.service';
77
export * from './lib/route-service/scully-routes.service';
88
export * from './lib/scully-content/scully-content.component';
9-
export * from './lib/utils/isScully'
9+
export * from './lib/utils/isScully';
1010

scully/renderPlugins/contentRenderPlugin.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import {readFileSync} from 'fs';
22
import {FilePlugin, plugins, registerPlugin} from '../pluginManagement/pluginRepository';
33
import {logError, yellow, logWarn} from '../utils/log';
44
import {HandledRoute} from '../routerPlugins/addOptionalRoutesPlugin';
5-
// import * as fm from 'front-matter';
6-
// import fm, {test} from 'front-matter'
7-
// import * as fm from 'front-matter';
85
const fm = require('front-matter');
96

107
registerPlugin('render', 'contentFolder', contentRenderPlugin);
@@ -25,13 +22,7 @@ async function contentRenderPlugin(html: string, route: HandledRoute) {
2522
}
2623
}
2724

28-
function insertContent(
29-
startTag: string,
30-
endTag: string,
31-
html: string,
32-
insertText: string,
33-
...extras
34-
) {
25+
function insertContent(startTag: string, endTag: string, html: string, insertText: string, ...extras) {
3526
try {
3627
const [openingText, rest] = html.split(startTag);
3728
const [takeout, endText] = rest.split(endTag);
@@ -61,7 +52,11 @@ async function handleFile(extension: string, fileContent: string) {
6152
return plugin.handler(fileContent) as Promise<string>;
6253
}
6354

64-
function getScript() {
65-
return `<script>try {window['scullyContent'] = document.body.innerHTML.split('<!--scullyContent-begin-->')[1].split('<!--scullyContent-end-->')[0];} catch(e) {console.error('scully could not pare content',e);}</script>
66-
`;
55+
/**
56+
* @returns a string representing the script that parses the page and loads the scullyContent variable.
57+
* The string is kept on one line as the focus is to keep it as small as possible.
58+
*/
59+
function getScript(): string {
60+
// tslint:disable-next-line:no-unused-expression
61+
return `<script>try {window['scullyContent'] = document.body.innerHTML.split('<!--scullyContent-begin-->')[1].split('<!--scullyContent-end-->')[0];} catch(e) {console.error('scully could not parse content',e);}</script>`;
6762
}

scully/renderPlugins/routeContentRenderer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {plugins} from '../pluginManagement/pluginRepository';
22
import {HandledRoute} from '../routerPlugins/addOptionalRoutesPlugin';
33
import {logError, yellow} from '../utils/log';
44
import {puppeteerRender} from './puppeteerRenderPlugin';
5-
import { scullyConfig } from '../utils/config';
65

76
export const routeContentRenderer = async (route: HandledRoute) => {
87
const html = await puppeteerRender(route);

scully/utils/compileConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const compileConfig = async (): Promise<ScullyConfig> => {
2323
configValidator,
2424
routeSplit,
2525
global,
26-
require: (path: string) => (path.startsWith('@') ? require(path) : require(join(angularRoot, path))),
26+
require: (requirePath: string) => (requirePath.startsWith('@') ? require(requirePath) : require(join(angularRoot, requirePath))),
2727
});
2828
// const tsCompilerConfig: CreateOptions = {
2929
// logError: true,

scully/utils/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const updateScullyConfig = async (config: Partial<ScullyConfig>) => {
5858
const newConfig = Object.assign({}, scullyConfig, config);
5959
if (config.outFolder === undefined) {
6060
logWarn(
61-
`The option outFolder isn't configures, we are using "${yellow(scullyConfig.outFolder)} by default now"`
61+
`The option outFolder isn't configured, we are using "${yellow(scullyConfig.outFolder)} by default."`
6262
);
6363
} else {
6464
config.outFolder = join(angularRoot, config.outFolder);

scully/utils/defaultAction.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {addOptionalRoutes, HandledRoute} from '../routerPlugins/addOptionalRoute
44
import {traverseAppRoutes} from '../routerPlugins/traverseAppRoutesPlugin';
55
import {storeRoutes} from '../systemPlugins/storeRoutes';
66
import {writeToFs} from '../systemPlugins/writeToFs.plugin';
7-
import {updateScullyConfig, loadConfig} from '../utils/config';
7+
import {updateScullyConfig, loadConfig} from './config';
88
import {ScullyConfig} from './interfacesandenums';
99
import {log} from './log';
1010
import {cpus} from 'os';
@@ -20,31 +20,31 @@ export const generateAll = async (config?: Partial<ScullyConfig>) => {
2020
log('Finding all routes in application.');
2121
const appRouteArray = await traverseAppRoutes();
2222
log('Pull in data to create additional routes.');
23-
const dataroutes = await addOptionalRoutes(appRouteArray);
24-
storeRoutes(dataroutes);
23+
const dataRoutes = await addOptionalRoutes(appRouteArray);
24+
await storeRoutes(dataRoutes);
2525
/** launch the browser, its shared among renderers */
2626
const browser = await launchedBrowser();
27-
/** start handling each route, works in chunked parrallel mode */
28-
// await doChunks(dataroutes);
29-
await renderParralell(dataroutes);
27+
/** start handling each route, works in chunked parallel mode */
28+
// await doChunks(dataRoutes);
29+
await renderParallel(dataRoutes);
3030
/** save router to static json thingie */
31-
storeRoutes(dataroutes);
32-
return dataroutes;
31+
await storeRoutes(dataRoutes);
32+
return dataRoutes;
3333
} catch (e) {
3434
// TODO: add better error handling
3535
log(e);
3636
}
3737
return [];
3838
};
3939

40-
async function renderParralell(dataroutes) {
40+
async function renderParallel(dataRoutes) {
4141
const renderRoute = route =>
4242
routeContentRenderer(route).then((html: string) => writeToFs(route.route, html));
43-
return asyncPool(cpus().length, dataroutes, renderRoute);
43+
return asyncPool(cpus().length, dataRoutes, renderRoute);
4444
}
4545

46-
async function doChunks(dataroutes) {
47-
const chunked = chunk(dataroutes, cpus().length);
46+
async function doChunks(dataRoutes) {
47+
const chunked = chunk(dataRoutes, cpus().length);
4848

4949
return chunked.reduce(async (acc, part) => {
5050
const x = await acc;

scully/utils/findAngularJsonPath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {dirname, resolve} from 'path';
1+
import {resolve} from 'path';
22
import {existsSync, statSync} from 'fs';
33

44
export function findAngularJsonPath(path?: string): string {

0 commit comments

Comments
 (0)