Skip to content

Commit

Permalink
fix: linted
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Jan 24, 2024
1 parent 852b322 commit cd827c1
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion docs/assets/theme/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Theme {

blocks[n] = blocks[n].replaceAll( /<([\w.]+)(\[\])?\\>/g, ( match, type, array ) => {
if ( type in types ) {
return `<[${type}${array ?? ""}](${types[type]})\\>`;
return `<[${ type }${ array ?? "" }](${ types[type] })\\>`;
}
else {
return match;
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/git/commit-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export default class extends Command {

// check type
if ( pkg.commitsConfig.types.size && !pkg.commitsConfig.types.has( commit.type ) ) {
this.#throwError( `Commit type is invalid. Allowed types: ${[ ...pkg.commitsConfig.types ].map( item => `"${item}"` ).join( ", " )}.` );
this.#throwError( `Commit type is invalid. Allowed types: ${ [ ...pkg.commitsConfig.types ].map( item => `"${ item }"` ).join( ", " ) }.` );
}

// check scope
if ( commit.scope ) {
if ( pkg.commitsConfig.scopes.size && !pkg.commitsConfig.scopes.has( commit.scope ) ) {
this.#throwError( `Commit scope is invalid. Allowed scopes: ${[ ...pkg.commitsConfig.scopes ].map( item => `"${item}"` ).join( ", " )}.` );
this.#throwError( `Commit scope is invalid. Allowed scopes: ${ [ ...pkg.commitsConfig.scopes ].map( item => `"${ item }"` ).join( ", " ) }.` );
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class extends Command {
status = await git.getStatus(),
changes = ( await git.getChanges( status.data.currentVersion ) ).data;

console.log( `Changelog since the version: ${status.data.currentVersion.isNull ? "-" : status.data.currentVersion}\n` );
console.log( `Changelog since the version: ${ status.data.currentVersion.isNull ? "-" : status.data.currentVersion }\n` );

for ( const commit of changes.changes ) {
console.log( "- " + commit.subject );
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export default class extends Command {
const html = `
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${data.encoding}">
<meta http-equiv="Content-Type" content="text/html; charset=${ data.encoding }">
</head>
<body>
<pre style="font-family: '${data.font}' !important; font-size: 12pt; white-space: pre-wrap;">
${data.data}
<pre style="font-family: '${ data.font }' !important; font-size: 12pt; white-space: pre-wrap;">
${ data.data }
</pre>
</body>
</html>
Expand Down
32 changes: 16 additions & 16 deletions lib/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ export default class extends Command {
const pkg = rootPackage.config;

console.log( `
Name: ${ansi.hl( pkg.name )}
Private: ${pkg.private ? ansi.error( " PRIVATE " ) : ansi.ok( " PUBLIC " )}
Branch: ${ansi.hl( status.branch )}
Current release: ${ansi.hl( status.currentVersion.isNull ? "-" : status.currentVersion )}
Stable release (latest): ${ansi.hl( status.releases.lastStableVersion.isNull ? "-" : status.releases.lastStableVersion )}
Last release (next): ${ansi.hl( status.releases.lastVersion.isNull ? "-" : status.releases.lastVersion )}
Is dirty: ${status.isDirty ? ansi.error( " DIRTY " ) : ansi.ok( " COMMITED " )}
Not pushed commits: ${Object.keys( status.pushStatus )
Name: ${ ansi.hl( pkg.name ) }
Private: ${ pkg.private ? ansi.error( " PRIVATE " ) : ansi.ok( " PUBLIC " ) }
Branch: ${ ansi.hl( status.branch ) }
Current release: ${ ansi.hl( status.currentVersion.isNull ? "-" : status.currentVersion ) }
Stable release (latest): ${ ansi.hl( status.releases.lastStableVersion.isNull ? "-" : status.releases.lastStableVersion ) }
Last release (next): ${ ansi.hl( status.releases.lastVersion.isNull ? "-" : status.releases.lastVersion ) }
Is dirty: ${ status.isDirty ? ansi.error( " DIRTY " ) : ansi.ok( " COMMITED " ) }
Not pushed commits: ${ Object.keys( status.pushStatus )
.map( branch => branch + ":" + ( status.pushStatus[branch] ? ansi.error( " " + status.pushStatus[branch] + " " ) : ansi.ok( " PUSHED " ) ) )
.join( ", " )}
Unreleased commits: ${status.currentVersionDistance ? ( !status.currentVersion.isNull ? ansi.error( " " + status.currentVersionDistance + " " ) : status.currentVersionDistance ) : ansi.ok( " RELEASED " )}
.join( ", " ) }
Unreleased commits: ${ status.currentVersionDistance ? ( !status.currentVersion.isNull ? ansi.error( " " + status.currentVersionDistance + " " ) : status.currentVersionDistance ) : ansi.ok( " RELEASED " ) }
`.trim() );

if ( upstream ) {
console.log();

console.log( `
Home: ${ansi.hl( upstream.homeUrl )}
Issues: ${ansi.hl( upstream.issuesUrl )}
Wiki: ${ansi.hl( upstream.wikiUrl )}
Docs: ${ansi.hl( upstream.docsUrl || "-" )}
Home: ${ ansi.hl( upstream.homeUrl ) }
Issues: ${ ansi.hl( upstream.issuesUrl ) }
Wiki: ${ ansi.hl( upstream.wikiUrl ) }
Docs: ${ ansi.hl( upstream.docsUrl || "-" ) }
Clone: ${ansi.hl( upstream.sshCloneUrl )}
Clone wiki: ${ansi.hl( upstream.sshWikiCloneUrl )}
Clone: ${ ansi.hl( upstream.sshCloneUrl ) }
Clone wiki: ${ ansi.hl( upstream.sshWikiCloneUrl ) }
`.trim() );
}

Expand Down
10 changes: 5 additions & 5 deletions lib/get-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class GetText {

if ( !EXTNAMES.has( extname ) ) return result( 200 );

if ( !fs.existsSync( this.#absolutePath ) ) return this.#error( `File ${this.#absolutePath} not found` );
if ( !fs.existsSync( this.#absolutePath ) ) return this.#error( `File ${ this.#absolutePath } not found` );

const content = fs.readFileSync( this.#absolutePath, "utf8" );

Expand All @@ -62,7 +62,7 @@ export default class GetText {

if ( start.line === 1 ) start.column -= 10;

this.#parse( `<template>${sfc.descriptor.template.content}</template>`, parseVueTemplate, vueTemplateParserOptions, {
this.#parse( `<template>${ sfc.descriptor.template.content }</template>`, parseVueTemplate, vueTemplateParserOptions, {
start,
} );
}
Expand Down Expand Up @@ -178,10 +178,10 @@ export default class GetText {
start,
} );

message = `Error at ${line}:${column} in the file: ${this.#packageRelativePath}\n` + message;
message = `Error at ${ line }:${ column } in the file: ${ this.#packageRelativePath }\n` + message;
}
else {
message = `Error in the file: ${this.#packageRelativePath}\n` + message;
message = `Error in the file: ${ this.#packageRelativePath }\n` + message;
}

return result( [ 500, message ] );
Expand Down Expand Up @@ -274,7 +274,7 @@ export default class GetText {
start,
} );

const reference = `${this.#relativePath}:${line}:${column}`;
const reference = `${ this.#relativePath }:${ line }:${ column }`;

message.references = reference;

Expand Down
12 changes: 6 additions & 6 deletions lib/git/changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Commit {

// properties
get subjectId () {
this.#subjectId ??= this.#type ? `${this.#type}(${this.#scope}):${this.#description}` : this.#description;
this.#subjectId ??= this.#type ? `${ this.#type }(${ this.#scope }):${ this.#description }` : this.#description;

return this.#subjectId;
}
Expand Down Expand Up @@ -87,7 +87,7 @@ class Commit {
}

get subject () {
this.#subject ??= this.#type ? `${this.#type}${this.#scope ? `(${this.#scope})` : ""}${this.#breaking ? "!" : ""}: ${this.#description}` : this.#description;
this.#subject ??= this.#type ? `${ this.#type }${ this.#scope ? `(${ this.#scope })` : "" }${ this.#breaking ? "!" : "" }: ${ this.#description }` : this.#description;

return this.#subject;
}
Expand Down Expand Up @@ -203,10 +203,10 @@ export default class Changes {

// public
report () {
console.log( `Total changes: ${this.total || "-"}` );
console.log( `Breaking changes: ${this.breaking.length || "-"}` );
console.log( `Features: ${this.feat.length || "-"}` );
console.log( `Fixes: ${this.fix.length || "-"}` );
console.log( `Total changes: ${ this.total || "-" }` );
console.log( `Breaking changes: ${ this.breaking.length || "-" }` );
console.log( `Features: ${ this.feat.length || "-" }` );
console.log( `Fixes: ${ this.fix.length || "-" }` );
}

// private
Expand Down
2 changes: 1 addition & 1 deletion lib/lint/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default class LintFile {

table.add( {
severity,
"line": `${msg.line}:${msg.column}`,
"line": `${ msg.line }:${ msg.column }`,
"description": msg.ruleId + ", " + msg.message,
} );
}
Expand Down
28 changes: 14 additions & 14 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default class Package {
get npmUrl () {
if ( this.isPrivate || !this.name ) return null;

return `https://www.npmjs.com/package/${this.name}`;
return `https://www.npmjs.com/package/${ this.name }`;
}

get commitsConfig () {
Expand Down Expand Up @@ -307,7 +307,7 @@ export default class Package {

this.#clearCache();

const addTags = [ latestTag, nextTag ].filter( tag => tag ).map( tag => `"${tag}"` ),
const addTags = [ latestTag, nextTag ].filter( tag => tag ).map( tag => `"${ tag }"` ),
removeTags = [];

// publish npm package
Expand All @@ -319,7 +319,7 @@ export default class Package {
params.push( "--tag", "no-tag" );
removeTags.push( "no-tag" );
}
params.push( `"${this.root}"` );
params.push( `"${ this.root }"` );

while ( 1 ) {
console.log( "Publishing:", "npm", params.join( " " ) );
Expand All @@ -339,7 +339,7 @@ export default class Package {
// add additional tags
if ( addTags.length ) {
for ( const tag of addTags ) {
params = [ "dist-tag", "add", `"${this.name + "@" + this.version}"`, tag ];
params = [ "dist-tag", "add", `"${ this.name + "@" + this.version }"`, tag ];

while ( 1 ) {
console.log( "Adding tag:", "npm", params.join( " " ) );
Expand All @@ -348,7 +348,7 @@ export default class Package {

// error
if ( res.status ) {
console.log( `Unable to add tag "${tag}"` );
console.log( `Unable to add tag "${ tag }"` );

if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "y" ) continue;
}
Expand All @@ -361,7 +361,7 @@ export default class Package {
// remove temporary tags
if ( removeTags.length ) {
for ( const tag of removeTags ) {
params = [ "dist-tag", "rm", `"${this.name}"`, tag ];
params = [ "dist-tag", "rm", `"${ this.name }"`, tag ];

while ( 1 ) {
console.log( "Removing tag:", "npm", params.join( " " ) );
Expand All @@ -370,7 +370,7 @@ export default class Package {

// error
if ( res.status ) {
console.log( `Unable to remove tag "${tag}"` );
console.log( `Unable to remove tag "${ tag }"` );

if ( ( await confirm( "Repeat?", [ "y", "n" ] ) ) === "y" ) continue;
}
Expand All @@ -397,10 +397,10 @@ export default class Package {
dependencyRange = new Semver.Range( dependencyRange );

try {
if ( dependencyRange.isPreRelease ) return result( [ 500, `Package "${this.name}" has pre-release dependency "${dependencyName}@${config[name][dependencyName]}"` ] );
if ( dependencyRange.isPreRelease ) return result( [ 500, `Package "${ this.name }" has pre-release dependency "${ dependencyName }@${ config[name][dependencyName] }"` ] );
}
catch ( e ) {
return result( [ 500, `Unable to parse dependency version "${dependencyName + "@" + config[name][dependencyName]}"` ] );
return result( [ 500, `Unable to parse dependency version "${ dependencyName + "@" + config[name][dependencyName] }"` ] );
}
}
}
Expand All @@ -418,7 +418,7 @@ export default class Package {

async test ( options = {} ) {
if ( !fs.existsSync( this.root + "/__tests__" ) ) {
console.log( `Tests for package "${this.name}": ${ansi.warn( " NOT FOUND " )}` );
console.log( `Tests for package "${ this.name }": ${ ansi.warn( " NOT FOUND " ) }` );

return result( 200 );
}
Expand All @@ -430,19 +430,19 @@ export default class Package {
const res = await runner.run( options );

if ( res.ok ) {
console.log( `Tests for package "${this.name}": ${ansi.ok( " PASS " )}` );
console.log( `Tests for package "${ this.name }": ${ ansi.ok( " PASS " ) }` );
}
else {
console.log( res + "" );
console.log( `Tests for package "${this.name}": ${ansi.error( " FAIL " )}` );
console.log( `Tests for package "${ this.name }": ${ ansi.error( " FAIL " ) }` );
}

return res;
}

async testPlan ( options = {} ) {
if ( !fs.existsSync( this.root + "/__tests__" ) ) {
if ( !options.json ) console.log( `Tests plan for package "${this.name}": ${ansi.warn( " NOT FOUND " )}` );
if ( !options.json ) console.log( `Tests plan for package "${ this.name }": ${ ansi.warn( " NOT FOUND " ) }` );

return;
}
Expand All @@ -451,7 +451,7 @@ export default class Package {

await runner.loadModules( url.pathToFileURL( this.root + "/__tests__" ) );

if ( !options.json ) console.log( `Tests plan for package "${this.name}"` );
if ( !options.json ) console.log( `Tests plan for package "${ this.name }"` );

return runner.plan( options, true );
}
Expand Down
10 changes: 5 additions & 5 deletions lib/package/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Docs {
if ( !this.isExists ) throw result( [ 404, `Documentation config wasn't found.` ] );

// validate docs config
if ( !configValidator( this.#rootPackage.docsConfig ) ) throw `Docs config is invalid:\n${configValidator.errors}`;
if ( !configValidator( this.#rootPackage.docsConfig ) ) throw `Docs config is invalid:\n${ configValidator.errors }`;

const options = await Options.new( this.#rootPackage, this.#rootPackage.docsConfig );

Expand Down Expand Up @@ -250,7 +250,7 @@ export default class Docs {
}
}
else {
throw result( [ 500, `Code block in file "${file}" has no language identifier:\n${match}` ] );
throw result( [ 500, `Code block in file "${ file }" has no language identifier:\n${ match }` ] );
}
} );

Expand All @@ -274,7 +274,7 @@ export default class Docs {
await options.addType( type );
}
else {
warn.push( `${ansi.warn( ` warn ` )} Type "${type}" in file "${file}" is undefined` );
warn.push( `${ ansi.warn( ` warn ` ) } Type "${ type }" in file "${ file }" is undefined` );
}
}
}
Expand Down Expand Up @@ -312,14 +312,14 @@ export default class Docs {
// pages created
if ( res.ok ) {
if ( path === res.data.source.path ) {
throw result( [ 200, `OK, branch: "${res.data.source.branch}", path: "${res.data.source.path}"` ] );
throw result( [ 200, `OK, branch: "${ res.data.source.branch }", path: "${ res.data.source.path }"` ] );
}

// update location
else {
res = await github.updatePages( upstream.repoId, { "source": { branch, path } } );

if ( res.ok ) throw result( [ 200, `Updated, branch: "${branch}", path: "${path}"` ] );
if ( res.ok ) throw result( [ 200, `Updated, branch: "${ branch }", path: "${ path }"` ] );
}
}

Expand Down
12 changes: 6 additions & 6 deletions lib/package/docs/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default class Options {
if ( this.logo ) {
options.logo = this.logo.href;

if ( this.logo.width ) options.logo += ` width="${this.logo.width}"`;
if ( this.logo.height ) options.logo += ` height="${this.logo.height}"`;
if ( this.logo.width ) options.logo += ` width="${ this.logo.width }"`;
if ( this.logo.height ) options.logo += ` height="${ this.logo.height }"`;
}

// alias
Expand Down Expand Up @@ -204,15 +204,15 @@ export default class Options {
const res = await fetch( url );

// http request error
if ( !res.ok ) throw `Unable to load external types from: ${url.href}`;
if ( !res.ok ) throw `Unable to load external types from: ${ url.href }`;

let config;

try {
config = yaml.parse( await res.text() );
}
catch ( e ) {
throw `Unable to parse: ${url.href}`;
throw `Unable to parse: ${ url.href }`;
}

// external config has no types defined
Expand Down Expand Up @@ -286,10 +286,10 @@ export default class Options {

// private
#buildLinkTag ( link, href ) {
var tag = `<a href="${href || link.href}"${link.title ? ` title="${link.title}"` : ""}>`;
var tag = `<a href="${ href || link.href }"${ link.title ? ` title="${ link.title }"` : "" }>`;

const text = [];
if ( link.iconCls ) text.push( `<i class="${link.iconCls}"></i>` );
if ( link.iconCls ) text.push( `<i class="${ link.iconCls }"></i>` );
if ( link.text ) text.push( link.text );

tag += text.join( " " );
Expand Down
Loading

0 comments on commit cd827c1

Please sign in to comment.