1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2026-06-12 06:25:27 -04:00

Switch to xo for linting

This commit is contained in:
XhmikosR
2023-05-16 21:22:45 +03:00
parent 0bfb798db8
commit 1e4307eaf9
5 changed files with 8345 additions and 29 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ const { hugoVersion } = JSON.parse(await fs.readFile(pkg));
const destDir = path.join(fileURLToPath(new URL('../vendor/', import.meta.url))); const destDir = path.join(fileURLToPath(new URL('../vendor/', import.meta.url)));
const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo'; const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
const extendedBin = (baseDownloadUrl) => new BinWrapper() const extendedBin = baseDownloadUrl => new BinWrapper()
.src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64') .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64')
.src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64') .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64')
.src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_linux-amd64.tar.gz`, 'linux', 'x64') .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_linux-amd64.tar.gz`, 'linux', 'x64')
@@ -27,7 +27,7 @@ const extendedBin = (baseDownloadUrl) => new BinWrapper()
.dest(destDir) .dest(destDir)
.use(binName); .use(binName);
const normalBin = (baseDownloadUrl) => new BinWrapper() const normalBin = baseDownloadUrl => new BinWrapper()
.src(`${baseDownloadUrl}hugo_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64') .src(`${baseDownloadUrl}hugo_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64')
.src(`${baseDownloadUrl}hugo_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64') .src(`${baseDownloadUrl}hugo_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64')
.src(`${baseDownloadUrl}hugo_${hugoVersion}_dragonfly-amd64.tar.gz`, 'dragonflybsd', 'x64') .src(`${baseDownloadUrl}hugo_${hugoVersion}_dragonfly-amd64.tar.gz`, 'dragonflybsd', 'x64')
+8290 -2
View File
File diff suppressed because it is too large Load Diff
+35 -4
View File
@@ -35,12 +35,12 @@
}, },
"devDependencies": { "devDependencies": {
"bin-check": "^4.1.0", "bin-check": "^4.1.0",
"eslint": "^8.40.0", "uvu": "^0.5.6",
"uvu": "^0.5.6" "xo": "^0.54.2"
}, },
"scripts": { "scripts": {
"lint": "eslint .", "lint": "xo",
"fix": "npm run lint -- --fix", "fix": "xo --fix",
"uvu": "uvu test", "uvu": "uvu test",
"test": "npm run lint && npm run uvu", "test": "npm run lint && npm run uvu",
"postinstall": "node lib/install.js" "postinstall": "node lib/install.js"
@@ -52,5 +52,36 @@
], ],
"engines": { "engines": {
"node": "^14.14.0 || >=16.0.0" "node": "^14.14.0 || >=16.0.0"
},
"xo": {
"space": true,
"rules": {
"arrow-body-style": "off",
"camelcase": [
"error",
{
"properties": "never"
}
],
"capitalized-comments": "off",
"comma-dangle": [
"error",
"never"
],
"operator-linebreak": [
"error",
"after"
],
"object-curly-spacing": [
"error",
"always"
],
"space-before-function-paren": [
"error",
"never"
],
"unicorn/prefer-top-level-await": "off",
"unicorn/prevent-abbreviations": "off"
}
} }
} }
+7 -10
View File
@@ -1,7 +1,7 @@
import process from 'node:process'; import process from 'node:process';
import binCheck from 'bin-check'; import binCheck from 'bin-check';
import { suite } from 'uvu'; import { suite } from 'uvu';
import * as assert from 'uvu/assert'; import * as assert from 'uvu/assert'; // eslint-disable-line n/file-extension-in-import
import hugoBin from '../index.js'; import hugoBin from '../index.js';
import hugoLib from '../lib/index.js'; import hugoLib from '../lib/index.js';
@@ -17,7 +17,6 @@ worksSuite.run();
/** /**
* Verify Custom/Enterprise Repository overwrite. * Verify Custom/Enterprise Repository overwrite.
*/ */
const customRepoSuite = suite('overwrites download repository'); const customRepoSuite = suite('overwrites download repository');
customRepoSuite.before.each(() => { customRepoSuite.before.each(() => {
@@ -32,10 +31,9 @@ customRepoSuite('verify test env', () => {
}); });
// Default Repository - Test Cases // Default Repository - Test Cases
customRepoSuite('should return default repository url - Repository: default - Extended: undefined', async() => { customRepoSuite('should return default repository url - Repository: default - Extended: undefined', async() => {
const lib = await hugoLib(process.cwd()); const lib = await hugoLib(process.cwd());
const repoSources = lib._src.map((v) => v.url); const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) { for (const sourceUrl of repoSources) {
assert.is(sourceUrl.startsWith('https://github.com/'), true); assert.is(sourceUrl.startsWith('https://github.com/'), true);
@@ -45,7 +43,7 @@ customRepoSuite('should return default repository url - Repository: default - Ex
customRepoSuite('should return default repository url - Repository: default - Extended: empty', async() => { customRepoSuite('should return default repository url - Repository: default - Extended: empty', async() => {
process.env.npm_config_hugo_bin_build_tags = ''; process.env.npm_config_hugo_bin_build_tags = '';
const lib = await hugoLib(process.cwd()); const lib = await hugoLib(process.cwd());
const repoSources = lib._src.map((v) => v.url); const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) { for (const sourceUrl of repoSources) {
assert.is(sourceUrl.startsWith('https://github.com/'), true); assert.is(sourceUrl.startsWith('https://github.com/'), true);
@@ -55,7 +53,7 @@ customRepoSuite('should return default repository url - Repository: default - Ex
customRepoSuite('should return default repository url - Repository: default - Extended: extended', async() => { customRepoSuite('should return default repository url - Repository: default - Extended: extended', async() => {
process.env.npm_config_hugo_bin_build_tags = 'extended'; process.env.npm_config_hugo_bin_build_tags = 'extended';
const lib = await hugoLib(process.cwd()); const lib = await hugoLib(process.cwd());
const repoSources = lib._src.map((v) => v.url); const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) { for (const sourceUrl of repoSources) {
assert.is(sourceUrl.startsWith('https://github.com/'), true); assert.is(sourceUrl.startsWith('https://github.com/'), true);
@@ -63,11 +61,10 @@ customRepoSuite('should return default repository url - Repository: default - Ex
}); });
// Custom/Enterprise Repository Test Cases // Custom/Enterprise Repository Test Cases
customRepoSuite('should return custom repository url - Repository: custom - Extended: undefined', async() => { customRepoSuite('should return custom repository url - Repository: custom - Extended: undefined', async() => {
process.env.npm_config_hugo_bin_download_repo = 'https://some1.example.com'; process.env.npm_config_hugo_bin_download_repo = 'https://some1.example.com';
const lib = await hugoLib(process.cwd()); const lib = await hugoLib(process.cwd());
const repoSources = lib._src.map((v) => v.url); const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) { for (const sourceUrl of repoSources) {
assert.is(sourceUrl.startsWith('https://some1.example.com/'), true); assert.is(sourceUrl.startsWith('https://some1.example.com/'), true);
@@ -78,7 +75,7 @@ customRepoSuite('should return custom repository url - Repository: custom - Exte
process.env.npm_config_hugo_bin_build_tags = ''; process.env.npm_config_hugo_bin_build_tags = '';
process.env.npm_config_hugo_bin_download_repo = 'https://some2.example.com'; process.env.npm_config_hugo_bin_download_repo = 'https://some2.example.com';
const lib = await hugoLib(process.cwd()); const lib = await hugoLib(process.cwd());
const repoSources = lib._src.map((v) => v.url); const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) { for (const sourceUrl of repoSources) {
assert.is(sourceUrl.startsWith('https://some2.example.com/'), true); assert.is(sourceUrl.startsWith('https://some2.example.com/'), true);
@@ -89,7 +86,7 @@ customRepoSuite('should return custom repository url - Repository: custom - Exte
process.env.npm_config_hugo_bin_build_tags = 'extended'; process.env.npm_config_hugo_bin_build_tags = 'extended';
process.env.npm_config_hugo_bin_download_repo = 'https://some3.example.com'; process.env.npm_config_hugo_bin_download_repo = 'https://some3.example.com';
const lib = await hugoLib(process.cwd()); const lib = await hugoLib(process.cwd());
const repoSources = lib._src.map((v) => v.url); const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) { for (const sourceUrl of repoSources) {
assert.is(sourceUrl.startsWith('https://some3.example.com/'), true); assert.is(sourceUrl.startsWith('https://some3.example.com/'), true);