Skip to content

Commit 5d4f59b

Browse files
author
David Enke
committed
chore: align to linter
1 parent f56808c commit 5d4f59b

15 files changed

Lines changed: 64 additions & 50 deletions

File tree

esbuild-plugin-add-declarations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { dirname, join, relative, resolve } from 'node:path';
2+
13
import type { Plugin } from 'esbuild';
24
import type { Program } from 'typescript';
35
import ts from 'typescript';
46

5-
import { dirname, join, relative, resolve } from 'node:path';
6-
7-
type PluginOptions = {
7+
interface PluginOptions {
88
filter: RegExp;
99
include: string[];
1010
sourceRoot: string;
1111
outdir: string;
12-
};
12+
}
1313

1414
function reportDiagnostics(program: Program): string {
1515
return ts.formatDiagnostics(ts.getPreEmitDiagnostics(program), {

esbuild-plugin-add-package.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import type { Plugin } from 'esbuild';
21
import { existsSync } from 'node:fs';
32
import { mkdir, readFile, writeFile } from 'node:fs/promises';
43
import { basename, dirname, join, relative, resolve } from 'node:path';
54
import { cwd } from 'node:process';
65

7-
import type { package as Package } from './package.d';
6+
import type { Plugin } from 'esbuild';
7+
8+
import type { package as Package } from './package.d.js';
89

9-
type ReadmeTemplateContext = {
10+
interface ReadmeTemplateContext {
1011
name: string;
1112
basePath: string;
1213
path: string;
1314
rootPackage: Package;
14-
};
15+
}
1516

16-
type PluginOptions = {
17+
interface PluginOptions {
1718
filter: RegExp;
1819
packageName: string;
1920

@@ -23,14 +24,14 @@ type PluginOptions = {
2324

2425
sourceRoot: string;
2526
outdir: string;
26-
};
27+
}
2728

2829
async function generatePackage(
2930
path: string,
3031
packageName: string,
3132
rootPackage: Package,
3233
src: string,
33-
dist: string
34+
dist: string,
3435
): Promise<void> {
3536
// resolve paths for package.json
3637
const baseFile = basename(path, '.ts');
@@ -71,7 +72,7 @@ async function generateReadme(
7172
readmeTemplate: PluginOptions['readmeTemplate'],
7273
rootPackage: Package,
7374
src: string,
74-
dist: string
75+
dist: string,
7576
): Promise<void> {
7677
// resolve paths for readme
7778
const basePath = dirname(relative(src, path));

esbuild.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { readFile } from 'node:fs/promises';
2+
import { resolve } from 'node:path';
3+
14
import { build } from 'esbuild';
25
import glob from 'fast-glob';
36

4-
import { resolve } from 'node:path';
5-
import { readFile } from 'node:fs/promises';
6-
7-
import { addDeclarations } from './esbuild-plugin-add-declarations';
8-
import { addPackageJson } from './esbuild-plugin-add-package';
7+
import { addDeclarations } from './esbuild-plugin-add-declarations.js';
8+
import { addPackageJson } from './esbuild-plugin-add-package.js';
99

1010
build({
1111
sourceRoot: 'src',

generate-package-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { writeFile } from 'node:fs/promises';
44
import { resolve } from 'node:path';
55
import { argv, cwd } from 'node:process';
6+
67
import { getJsonSchemaReader, getTypeScriptWriter, makeConverter } from 'typeconv';
78

89
// store generated types in cwd
@@ -11,6 +12,7 @@ const dist = resolve(cwd(), path);
1112

1213
// load schema
1314
const response = await fetch('https://json.schemastore.org/package.json');
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- we have no types here, but trust the schema to be correct
1416
const { $schema, title, definitions, ...schema } = (await response.json()) as any;
1517

1618
// as typeconv only looks inside the definitions object, we

globals.d.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
declare module '@custom-elements-manifest/to-markdown' {
22
import type { AnalyzePhaseParams } from '@custom-elements-manifest/analyzer';
3-
export type Options = {
3+
4+
export interface Options {
45
private: 'all' | 'details' | 'hidden';
56
headingOffset: number;
67
classNameFilter: string;
78
omitSections: string[];
89
omitDeclarations: string[];
9-
};
10+
}
1011
type ModuleDoc = AnalyzePhaseParams['moduleDoc'];
1112
export function customElementsManifestToMarkdown(
1213
manifest: { modules: ModuleDoc[] },
13-
options?: Partial<Options>
14+
options?: Partial<Options>,
1415
): string;
1516
}
1617

@@ -20,12 +21,13 @@ declare module '@custom-elements-manifest/analyzer/browser/index.js' {
2021
const create: (options: { modules: any[]; plugins: Plugin[]; context: { dev: boolean } }) => any;
2122
const ts: typeof import('typescript');
2223
const litPlugin: () => Plugin[];
23-
export { create, ts, litPlugin };
24+
export { create, litPlugin, ts };
2425
}
2526

2627
declare module 'esbuild-copy-static-files' {
2728
import type { Plugin } from 'esbuild';
28-
export type CopyStaticFilesOptions = {
29+
30+
export interface CopyStaticFilesOptions {
2931
src: string;
3032
dest: string;
3133
filter: (src: string, dest: string) => boolean;
@@ -35,7 +37,7 @@ declare module 'esbuild-copy-static-files' {
3537
force: boolean;
3638
preserveTimestamps: boolean;
3739
recursive: boolean;
38-
};
40+
}
3941
const copyStaticFiles: (options?: Partial<CopyStaticFilesOptions>) => Plugin;
4042
export default copyStaticFiles;
4143
}

src/cem-plugin-examples/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { readFile } from 'node:fs/promises';
22
import { join, resolve } from 'node:path';
3-
import type { SourceFile } from 'typescript';
43

54
// https://custom-elements-manifest.open-wc.org/analyzer/getting-started/#usage-in-the-browser
6-
import { ts, create, litPlugin } from '@custom-elements-manifest/analyzer/browser/index.js';
5+
import { create, litPlugin, ts } from '@custom-elements-manifest/analyzer/browser/index.js';
6+
import type { SourceFile } from 'typescript';
77

8-
import { customElementExamplesPlugin } from '.';
8+
import { customElementExamplesPlugin } from './index.js';
99

1010
describe('cem-plugin-examples', () => {
1111
let source: SourceFile;

src/cem-plugin-examples/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { existsSync, readFileSync } from 'node:fs';
22
import { dirname, resolve } from 'node:path';
3+
34
import type { Plugin } from '@custom-elements-manifest/analyzer';
4-
import { findDeclaration, hasJsDocComments } from '../utils/plugin.utils';
5+
6+
import { findDeclaration, hasJsDocComments } from '../utils/plugin.utils.js';
57

68
// as the plugin is create by factory function, we can provide some options
7-
type PluginOptions = {
9+
interface PluginOptions {
810
// the markdown file name to look for
911
exampleFileName?: string;
10-
};
12+
}
1113

1214
function isExampleTag(tag: CemJsDocTag): boolean {
1315
return tag.tagName.escapedText === 'example';
@@ -20,7 +22,7 @@ function isExampleTag(tag: CemJsDocTag): boolean {
2022
* So each module with annotated or file based examples will receive an additional `examples`
2123
* property containing them as strings.
2224
*/
23-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25+
2426
export function customElementExamplesPlugin(options?: Partial<PluginOptions>): Plugin {
2527
return {
2628
name: 'custom-element-examples',

src/cem-plugin-generate-readmes/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { existsSync } from 'node:fs';
22
import { readFile, rm, writeFile } from 'node:fs/promises';
33
import { join, resolve } from 'node:path';
4-
import type { SourceFile } from 'typescript';
54

65
// https://custom-elements-manifest.open-wc.org/analyzer/getting-started/#usage-in-the-browser
7-
import { ts, create, litPlugin } from '@custom-elements-manifest/analyzer/browser/index.js';
6+
import { create, litPlugin, ts } from '@custom-elements-manifest/analyzer/browser/index.js';
7+
import type { SourceFile } from 'typescript';
88

9-
import { customElementGenerateReadmesPlugin } from '.';
9+
import { customElementGenerateReadmesPlugin } from './index.js';
1010

1111
describe('cem-plugin-generate-readmes', () => {
1212
const target = join(__dirname, '.README.md');

src/cem-plugin-generate-readmes/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
22
import { dirname, resolve } from 'node:path';
33

44
import type { Plugin } from '@custom-elements-manifest/analyzer';
5-
import { type Options as CemOptions, customElementsManifestToMarkdown } from '@custom-elements-manifest/to-markdown';
5+
import type { Options as CemOptions } from '@custom-elements-manifest/to-markdown';
6+
import { customElementsManifestToMarkdown } from '@custom-elements-manifest/to-markdown';
67
import { analyzeText, transformAnalyzerResult } from 'web-component-analyzer';
78

8-
import { findDeclaration } from '../utils/plugin.utils';
9+
import { findDeclaration } from '../utils/plugin.utils.js';
910

1011
// as the plugin is create by factory function, we can provide some options
1112
type PluginOptions = {

src/cem-plugin-grouping/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { readFile } from 'node:fs/promises';
22
import { join, resolve } from 'node:path';
33

44
// https://custom-elements-manifest.open-wc.org/analyzer/getting-started/#usage-in-the-browser
5-
import { ts, create, litPlugin } from '@custom-elements-manifest/analyzer/browser/index.js';
5+
import { create, litPlugin, ts } from '@custom-elements-manifest/analyzer/browser/index.js';
66

7-
import { customElementGroupingPlugin } from '.';
7+
import { customElementGroupingPlugin } from './index.js';
88

99
describe('cem-plugin-grouping', () => {
1010
it('should add groups to manifest', async () => {

0 commit comments

Comments
 (0)