Skip to content

Commit

Permalink
Silence a bunch of lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Oct 31, 2024
1 parent 369c8a6 commit f910d9e
Show file tree
Hide file tree
Showing 35 changed files with 8,807 additions and 11,965 deletions.
5 changes: 2 additions & 3 deletions packages/@glimmer-workspace/build/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ export class Package {
}

/**
* @typedef {object} Formats
* @property {boolean} [ esm ] enabled by default
* @property {boolean} [ cjs ] enabled by default until eslint-plugin-ember and ember-source no longer need it
* @typedef {{esm?: boolean, cjs?: boolean}} Formats
* @param {Formats} [formats] enabled by default
*
* @returns {import("rollup").RollupOptions[] | import("rollup").RollupOptions}
*/
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer-workspace/test-utils/lib/guard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Expand, Maybe, Present } from '@glimmer/interfaces';
import { isPresent } from '@glimmer/util';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type NTuple<N extends number, Type, T extends any[] = []> = T['length'] extends N
? T
: NTuple<N, Type, [...T, Type]>;
Expand Down
12 changes: 2 additions & 10 deletions packages/@glimmer-workspace/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,9 @@
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"types": [
"qunit",
"node",
"vite/client"
]
"types": ["qunit", "node", "vite/client"]
},
"include": [
"./*/index.*",
"./*/lib/**/*",
"./*/test/**/*"
],
"include": ["./*/index.*", "./*/lib/**/*", "./*/test/**/*"],
"references": [
{
"path": "../@glimmer/tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/debug/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function debug(
let metadata = opcodeMetadata(op.type, isMachine);

if (!metadata) {
throw new Error(`Missing Opcode Metadata for ${op}`);
throw new Error(`Missing Opcode Metadata for ${op.type}`);
}

let out = Object.create(null);
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/debug/lib/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const OPERAND_TYPES = [
];

function isOperandType(s: string): s is OperandType {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return OPERAND_TYPES.indexOf(s as any) !== -1;
}

Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/debug/lib/stack-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ class SafeStringChecker implements Checker<SafeString> {

validate(value: unknown): value is SafeString {
return (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof value === 'object' && value !== null && typeof (value as any).toHTML === 'function'
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/global-context/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* This package contains global context functions for Glimmer. These functions
* are set by the embedding environment and must be set before initial render.
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type ExpressionSexpOpcodeMap = {
[TSexpOpcode in TupleExpression[0]]: Extract<TupleExpression, { 0: TSexpOpcode }>;
};

export interface SexpOpcodeMap extends ExpressionSexpOpcodeMap, StatementSexpOpcodeMap { }
export interface SexpOpcodeMap extends ExpressionSexpOpcodeMap, StatementSexpOpcodeMap {}
export type SexpOpcode = keyof SexpOpcodeMap;

export namespace Core {
Expand Down Expand Up @@ -372,7 +372,7 @@ export type SerializedTemplateBlock = [
hasDebug: boolean,
// upvars
upvars: string[],
lexicalSymbols?: string[]
lexicalSymbols?: string[],
];

/**
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/interfaces/lib/runtime/arguments.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface ArgumentsDebug {
}

export interface ArgumentError {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any;
}

Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/interfaces/lib/runtime/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export interface Environment {

isInteractive: boolean;
debugRenderTree?: DebugRenderTree | undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
isArgumentCaptureError?: ((error: any) => boolean) | undefined;
}
1 change: 1 addition & 0 deletions packages/@glimmer/manager/lib/internal/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type FnArgs<Args extends Arguments = Arguments> =
| [...Args['positional'], Args['named']]
| [...Args['positional']];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyFunction = (...args: any[]) => unknown;

interface State {
Expand Down
2 changes: 2 additions & 0 deletions packages/@glimmer/manager/lib/public/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class CustomComponentManager<O extends Owner, ComponentInstance>
throw new Error(
`Custom component managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.13')\` (imported via \`import { capabilities } from '@ember/component';\`). Received: \`${JSON.stringify(
delegate.capabilities
// eslint-disable-next-line @typescript-eslint/no-base-to-string
)}\` for: \`${delegate}\``
);
}
Expand All @@ -150,6 +151,7 @@ export class CustomComponentManager<O extends Owner, ComponentInstance>
}

getDebugName(definition: ComponentDefinitionState): string {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
return typeof definition === 'function' ? definition.name : definition.toString();
}

Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/manager/lib/public/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class CustomHelperManager<O extends Owner = Owner> implements InternalHel
throw new Error(
`Custom helper managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.23')\` (imported via \`import { capabilities } from '@ember/helper';\`). Received: \`${JSON.stringify(
delegate.capabilities
// eslint-disable-next-line @typescript-eslint/no-base-to-string
)}\` for: \`${delegate}\``
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/manager/lib/public/modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class CustomModifierManager<O extends Owner, ModifierInstance>
throw new Error(
`Custom modifier managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.22')\` (imported via \`import { capabilities } from '@ember/modifier';\`). Received: \`${JSON.stringify(
delegate.capabilities
// eslint-disable-next-line @typescript-eslint/no-base-to-string
)}\` for: \`${delegate}\``
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/manager/lib/util/args-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class PositionalArgsProxy implements ProxyHandler<[]> {
return valueForRef(positional[parsed]!);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (target as any)[prop];
}

Expand Down
73 changes: 61 additions & 12 deletions packages/@glimmer/manager/test/capabilities-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { InternalComponentManager } from '@glimmer/interfaces';
import { capabilityFlagsFrom, managerHasCapability } from '@glimmer/manager';
import { InternalComponentCapabilities } from '@glimmer/vm';

Expand Down Expand Up @@ -83,39 +84,87 @@ QUnit.test('allows querying bitmap for a capability', (assert) => {
});

assert.true(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.dynamicLayout)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.dynamicLayout
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.dynamicTag)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.dynamicTag
)
);
assert.true(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.prepareArgs)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.prepareArgs
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.createArgs)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.createArgs
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.attributeHook)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.attributeHook
)
);
assert.true(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.elementHook)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.elementHook
)
);
assert.true(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.dynamicScope)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.dynamicScope
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.createCaller)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.createCaller
)
);
assert.true(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.updateHook)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.updateHook
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.createInstance)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.createInstance
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.willDestroy)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.willDestroy
)
);
assert.false(
managerHasCapability({} as any, capabilities, InternalComponentCapabilities.hasSubOwner)
managerHasCapability(
{} as InternalComponentManager,
capabilities,
InternalComponentCapabilities.hasSubOwner
)
);
});
1 change: 1 addition & 0 deletions packages/@glimmer/manager/test/managers-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type {
ComponentManager,
HelperManager,
Expand Down
2 changes: 2 additions & 0 deletions packages/@glimmer/node/lib/serialize-builder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
import type {
Bounds,
ElementBuilder,
Expand Down Expand Up @@ -88,6 +89,7 @@ class SerializeBuilder extends NewElementBuilder implements ElementBuilder {
if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') {
return super.__appendText(string);
} else if (string === '') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.__appendComment('% %') as any as SimpleText;
} else if (current && current.nodeType === TEXT_NODE) {
this.__appendComment('%|%');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ function InvokeStaticComponent(
}

if (hasCapability(capabilities, InternalComponentCapabilities.createInstance)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
op(Op.CreateComponent, (blocks.has('default') as any) | 0, $s0);
}

Expand Down Expand Up @@ -399,6 +400,7 @@ export function invokePreparedComponent(
op(Op.BeginComponentTransaction, $s0);
op(Op.PushDynamicScope);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
op(Op.CreateComponent, (hasBlock as any) | 0, $s0);

// this has to run after createComponent to allow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export function resolveComponent(
assert(!meta.isStrictMode, 'Strict mode errors should already be handled at compile time');

throw new Error(
`Attempted to resolve a component in a strict mode template, but that value was not in scope: ${meta.upvars![expr[1]] ?? '{unknown variable}'
`Attempted to resolve a component in a strict mode template, but that value was not in scope: ${
meta.upvars![expr[1]] ?? '{unknown variable}'
}`
);
}
Expand Down Expand Up @@ -393,7 +394,8 @@ function lookupBuiltInHelper(
// Keyword helper did not exist, which means that we're attempting to use a
// value of some kind that is not in scope
throw new Error(
`Attempted to resolve a ${type} in a strict mode template, but that value was not in scope: ${meta.upvars![expr[1]] ?? '{unknown variable}'
`Attempted to resolve a ${type} in a strict mode template, but that value was not in scope: ${
meta.upvars![expr[1]] ?? '{unknown variable}'
}`
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/owner/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const OWNER: unique symbol = Symbol('OWNER') as any;

interface OwnedObject<O extends object> {
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/syntax/lib/generation/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
import type * as ASTv1 from '../v1/api';

const enum Char {
Expand Down
3 changes: 3 additions & 0 deletions packages/@glimmer/syntax/lib/traversal/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function getNodeHandler<N extends ASTv1.Node>(
visitor: NodeVisitor,
nodeType: N['type']
): NodeTraversal<ASTv1.Node> | undefined {
// eslint-disable-next-line deprecation/deprecation
if (visitor.Program) {
if (
(nodeType === 'Template' && !visitor.Template) ||
Expand All @@ -76,6 +77,7 @@ function getNodeHandler<N extends ASTv1.Node>(
`The 'Program' visitor node is deprecated. Use 'Template' or 'Block' instead (node was '${nodeType}') `
);

// eslint-disable-next-line deprecation/deprecation
return visitor.Program as NodeTraversal<ASTv1.Node>;
}
}
Expand Down Expand Up @@ -186,6 +188,7 @@ function visitKey<N extends ASTv1.Node>(
// TODO: dynamically check the results by having a table of
// expected node types in value space, not just type space

// eslint-disable-next-line @typescript-eslint/no-explicit-any
assignKey(node, key, value, result as any);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/syntax/test/legacy-interop-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable deprecation/deprecation */
import { builders as b } from '@glimmer/syntax';

QUnit.module('[glimmer-syntax] AST nodes legacy interop');
Expand Down
2 changes: 2 additions & 0 deletions packages/@glimmer/syntax/test/plugin-node-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ test('deprecated program visitor', (assert) => {
return {
name: 'plugin',
visitor: {
// eslint-disable-next-line deprecation/deprecation
Program(node: AST.Program) {
assert.step(node.type);
},
Expand All @@ -69,6 +70,7 @@ test('deprecated program visitor', (assert) => {
});

test('can support the legacy AST transform API via ASTPlugin', (assert) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function ensurePlugin(FunctionOrPlugin: any): ASTPluginBuilder {
if (FunctionOrPlugin.prototype && FunctionOrPlugin.prototype.transform) {
return (env: ASTPluginEnvironment) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/@glimmer/syntax/test/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type FromEntries<T extends [PropertyKey, unknown][]> = {
};

function fromEntries<T extends [PropertyKey, unknown][]>(entries: T): FromEntries<T> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const out: any = {};

for (const [key, value] of entries) {
Expand All @@ -40,7 +41,9 @@ function fromEntries<T extends [PropertyKey, unknown][]>(entries: T): FromEntrie
}

export function astEqual(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
actual: any | null | undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expected: any | null | undefined,
message?: string,
parseOptions?: PreprocessOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/util/lib/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LOCAL_LOGGER } from '../index';

// let alreadyWarned = false;

export function debugAssert(test: any, msg: string): asserts test {
export function debugAssert(test: unknown, msg: string): asserts test {
// if (!alreadyWarned) {
// alreadyWarned = true;
// Logger.warn("Don't leave debug assertions on in public builds");
Expand Down
Loading

0 comments on commit f910d9e

Please sign in to comment.