Skip to content

Commit

Permalink
chore: add @containerbase/eslint-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Nov 7, 2024
1 parent 7010a39 commit 6a7b4cc
Show file tree
Hide file tree
Showing 27 changed files with 44 additions and 30 deletions.
8 changes: 2 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import eslintContainerbase from '@containerbase/eslint-plugin';
import js from '@eslint/js';
import vitest from '@vitest/eslint-plugin';
import eslintConfigPrettier from 'eslint-config-prettier';
// @ts-expect-error no types available
import eslintPluginImport from 'eslint-plugin-import';
// @ts-expect-error no types available
import eslintPluginPromise from 'eslint-plugin-promise';
import globals from 'globals';
import tseslint from 'typescript-eslint';
Expand All @@ -29,11 +28,8 @@ export default tseslint.config(
eslintPluginImport.flatConfigs.typescript,
vitest.configs.recommended,
eslintPluginPromise.configs['flat/recommended'],
eslintContainerbase.configs.all,
{
plugins: {
'@vitest': vitest,
},

linterOptions: {
reportUnusedDisableDirectives: true,
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"zod": "3.23.8"
},
"devDependencies": {
"@containerbase/eslint-plugin": "1.1.0",
"@eslint/js": "9.14.0",
"@semantic-release/exec": "6.0.3",
"@tsconfig/node20": "20.1.4",
Expand Down
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli/command/download-file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('index', () => {
describe('cli/command/download-file', () => {
beforeEach(() => {
for (const key of Object.keys(env)) {
if (key.startsWith('URL_REPLACE_')) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/init-tool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('index', () => {
describe('cli/command/init-tool', () => {
test('init-tool', async () => {
const cli = new Cli({ binaryName: 'cli' });
prepareCommands(cli, null);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/install-gem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('install-gem', () => {
describe('cli/command/install-gem', () => {
beforeEach(() => {
delete env.RAKE_VERSION;
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/install-npm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('install-npm', () => {
describe('cli/command/install-npm', () => {
beforeEach(() => {
delete env.DEL_CLI_VERSION;
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/install-pip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('install-pip', () => {
describe('cli/command/install-pip', () => {
beforeEach(() => {
delete env.POETRY_VERSION;
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/install-tool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('install-tool', () => {
describe('cli/command/install-tool', () => {
beforeEach(() => {
delete env.NODE_VERSION;
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/prepare-tool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mocks = vi.hoisted(() => ({
vi.mock('../install-tool', () => mocks);
vi.mock('../prepare-tool', () => mocks);

describe('index', () => {
describe('cli/command/prepare-tool', () => {
test('prepare-tool', async () => {
const cli = new Cli({ binaryName: 'prepare-tool' });
prepareCommands(cli, 'prepare-tool');
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { env } from 'node:process';
import { beforeEach, describe, expect, test } from 'vitest';
import { getVersion, isToolIgnored } from './utils';

describe('utils', () => {
describe('cli/command/utils', () => {
beforeEach(() => {
delete env.NODE_VERSION;
delete env.DEL_CLI_VERSION;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const mocks = vi.hoisted(() => ({

vi.mock('./main', () => mocks);

describe('index', () => {
describe('cli/index', () => {
test('works', async () => {
await import('./index');
expect(mocks.main).toHaveBeenCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/install-tool/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vi.mock('execa');
vi.mock('../tools/bun');
vi.mock('../tools/php/composer');

describe('index', () => {
describe('cli/install-tool/index', () => {
beforeAll(async () => {
for (const p of [
'var/lib/containerbase/tool.prep.d',
Expand Down
2 changes: 1 addition & 1 deletion src/cli/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vi.mock('./utils/common', async (importActual) => ({
validateSystem: vi.fn(),
}));

describe('index', () => {
describe('cli/main', () => {
test('works', async () => {
expect(await main()).toBeUndefined();
});
Expand Down
2 changes: 1 addition & 1 deletion src/cli/prepare-tool/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vi.mock('node:process', async (importOriginal) => ({
geteuid: () => 0,
}));

describe('index', () => {
describe('cli/prepare-tool/index', () => {
beforeAll(async () => {
for (const p of [
'var/lib/containerbase/tool.prep.d',
Expand Down
2 changes: 1 addition & 1 deletion src/cli/proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { bootstrap } from './proxy';

vi.mock('global-agent', () => ({ createGlobalProxyAgent: vi.fn() }));

describe('proxy', () => {
describe('cli/proxy', () => {
const httpProxy = 'http://example.org/http-proxy';
const httpsProxy = 'http://example.org/https-proxy';
const noProxy = 'http://example.org/no-proxy';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/services/apt.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ vi.mock('node:fs/promises', async (importActual) => ({
...mocks,
}));

describe('apt.service', () => {
describe('cli/services/apt.service', () => {
let child!: Container;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/services/compression.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CompressionService, rootContainer } from '.';

vi.mock('execa');

describe('compression.service', () => {
describe('cli/services/compression.service', () => {
let child!: Container;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/services/env.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vi.mock('node:process', () => ({
geteuid: undefined,
}));

describe('env.service', () => {
describe('cli/services/env.service', () => {
let child!: Container;
let rootDir: string | undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/services/http.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { scope } from '~test/http-mock';
import { cachePath } from '~test/path';

const baseUrl = 'https://example.com';
describe('http.service', () => {
describe('cli/services/http.service', () => {
let child!: Container;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/services/path.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { fileRights, pathExists } from '../utils';
import { PathService, rootContainer } from '.';
import { rootPath } from '~test/path';

describe('path.service', () => {
describe('cli/services/path.service', () => {
const path = env.PATH;
let child!: Container;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/services/version.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { beforeEach, describe, expect, test } from 'vitest';
import { VersionService, rootContainer } from '.';
import { rootPath } from '~test/path';

describe('version.service', () => {
describe('cli/services/version.service', () => {
let child!: Container;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ vi.mock('node:os', () => ({ ...osMocks, default: osMocks }));
vi.mock('node:process', () => ({ ...procMocks, default: procMocks }));
vi.mock('del');

describe('common', () => {
describe('cli/utils/common', () => {
beforeEach(() => {
reset();
fsMocks.readFile.mockResolvedValueOnce(`PRETTY_NAME="Ubuntu 22.04.2 LTS"
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils/hash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { env } from 'node:process';
import { describe, expect, test } from 'vitest';
import { hash, hashFile } from './hash';

describe('hash', () => {
describe('cli/utils/hash', () => {
test('should hash data with sha256', () => {
expect(hash('https://example.com/test.txt', 'sha256')).toBe(
'd1dc63218c42abba594fff6450457dc8c4bfdd7c22acf835a50ca0e5d2693020',
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cliMode } from '.';
const procMocks = vi.hoisted(() => ({ argv0: '', env: {} }));
vi.mock('node:process', () => procMocks);

describe('index', () => {
describe('cli/utils/index', () => {
test('cliMode', async () => {
expect(cliMode()).toBeNull();
procMocks.argv0 = 'containerbase-cli';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils/logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { beforeEach, describe, expect, test, vi } from 'vitest';

// TODO: can't do full coverage because of some vitest mock issues.

describe('logger', () => {
describe('cli/utils/logger', () => {
beforeEach(() => {
vi.resetModules();
delete env.CONTAINERBASE_LOG_LEVEL;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils/versions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'vitest';
import { isValid, parse } from './versions';

describe('versions', () => {
describe('cli/utils/versions', () => {
test('isValid', () => {
expect(isValid('1.0.0')).toBe(true);
expect(isValid('abc')).toBe(false);
Expand Down

0 comments on commit 6a7b4cc

Please sign in to comment.