Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "dev",
"version": "1.0.0",
"description": "",
"type": "module",
"dependencies": {
"lit-element": "^2.3.1",
"lit-html": "^1.2.1",
Expand Down
4 changes: 3 additions & 1 deletion eslint.config.mjs → eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default tseslint.config(
},
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
tsconfigRootDir: import.meta.dirname,
sourceType: "module",
ecmaVersion: "latest"
}
},
rules: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"author": "JackRobards",
"license": "MIT",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/JackRobards/lit-analyzer.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SimpleType } from "ts-simple-type";
import type { HTMLDataV1 } from "vscode-html-languageservice";
import htmlDataJson from "@vscode/web-custom-data/data/browsers.html-data.json";
import htmlDataJson from "@vscode/web-custom-data/data/browsers.html-data.json" with { type: "json" };
import type { HtmlAttr, HtmlDataCollection } from "../parse/parse-html-data/html-tag.js";
import { parseVscodeHtmlData } from "../parse/parse-html-data/parse-vscode-html-data.js";
import { lazy } from "../util/general-util.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { IP5CommentNode, IP5DocumentFragmentNode, IP5NodeBase, IP5TagNode, IP5TextNode, P5Node } from "./parse-html-types.js";

const { parseFragment } = require("parse5");
import { parseFragment } from "parse5";

/**
* Returns if a p5Node is a tag node.
Expand Down Expand Up @@ -39,5 +38,5 @@ export function isCommentNode(node: P5Node): node is IP5CommentNode {
* @param html
*/
export function parseHtml(html: string): IP5DocumentFragmentNode {
return parseFragment(html, { sourceCodeLocationInfo: true, locationInfo: true });
return parseFragment(html, { sourceCodeLocationInfo: true }) as IP5DocumentFragmentNode;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-expect-error - need to upgrade to type module in package.json
import didYouMean, * as dym from "didyoumean2";
import type { Omit } from "./general-util.js";

Expand Down
3 changes: 2 additions & 1 deletion packages/lit-analyzer/src/scripts/check-version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as fs from "fs";
import * as path from "path";
// @ts-expect-error - This script file is run in a different "scope" - where the package.json file is at a different relative location
import pkg from "../package.json" with { type: "json" };

const pkg = require("../package.json");
const { version } = pkg;

const constantsPath = path.resolve("src/lib/analyze/constants.ts");
Expand Down
2 changes: 2 additions & 0 deletions packages/lit-analyzer/src/test/helpers/ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { ImplementationFn } from "ava";
import test from "ava";
import { dirname } from "path";
import type * as tsModule from "typescript";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
import { setTypescriptModule } from "../../lib/analyze/ts-module.js";

// Based on the `ava` types for test.only and test.skip. This matches the format of the tests in this repo
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-analyzer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": ["./src"],
"include": ["./src", "./package.json"],
"exclude": [],
"compilerOptions": {
"rootDir": "./src",
Expand Down
3 changes: 2 additions & 1 deletion packages/ts-lit-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Typescript plugin that adds type checking and code completion to lit-html. Fork of the original ts-lit-plugin.",
"author": "JackRobards",
"license": "MIT",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/JackRobards/lit-analyzer.git"
Expand Down Expand Up @@ -49,7 +50,7 @@
]
}
},
"main": "index.js",
"exports": "./index.js",
"files": [
"/lib/",
"/html-documentation/"
Expand Down
1 change: 1 addition & 0 deletions packages/ts-lit-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LitPluginContext } from "./ts-lit-plugin/lit-plugin-context.js";
import { TsLitPlugin } from "./ts-lit-plugin/ts-lit-plugin.js";
import { setTypescriptModule } from "./ts-module.js";

const __dirname = import.meta.dirname;
const tsHtmlPluginSymbol = Symbol.for("__tsHtmlPlugin__");

let context: LitPluginContext | undefined = undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-lit-plugin/esbuild.script.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ await esbuild.build({
external: ["typescript"],
minify: true,
target: "es2023",
format: "cjs",
format: "esm",
color: true,
mainFields: ["module", "main"]
});
18 changes: 10 additions & 8 deletions packages/vscode-lit-plugin/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LitAnalyzerConfig } from "@jackolope/lit-analyzer";
import { ALL_RULE_IDS } from "@jackolope/lit-analyzer";
import type { LitAnalyzerConfig } from "@jackolope/lit-analyzer" with { "resolution-mode": "import" };
const litAnalyzer = import("@jackolope/lit-analyzer");
import { join } from "path";
import { ColorProvider } from "./color-provider.js";
import * as vscode from "vscode";
Expand Down Expand Up @@ -32,9 +32,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>

// Subscribe to configuration change
vscode.workspace.onDidChangeConfiguration(
e => {
async e => {
if (e.affectsConfiguration(configurationSection) || e.affectsConfiguration(configurationExperimentalHtmlSection)) {
synchronizeConfig(api);
await synchronizeConfig(api);
}
},
undefined,
Expand All @@ -54,14 +54,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
);
context.subscriptions.push(registration);

synchronizeConfig(api);
await synchronizeConfig(api);
}

function synchronizeConfig(api: { configurePlugin: (pluginId: typeof tsLitPluginId, config: Partial<LitAnalyzerConfig>) => void }) {
api.configurePlugin(tsLitPluginId, getConfig());
async function synchronizeConfig(api: { configurePlugin: (pluginId: typeof tsLitPluginId, config: Partial<LitAnalyzerConfig>) => void }) {
api.configurePlugin(tsLitPluginId, await getConfig());
}

function getConfig(): Partial<LitAnalyzerConfig> {
async function getConfig(): Promise<Partial<LitAnalyzerConfig>> {
const config = vscode.workspace.getConfiguration(configurationSection);
const outConfig: Partial<LitAnalyzerConfig> = {};

Expand Down Expand Up @@ -151,6 +151,8 @@ function getConfig(): Partial<LitAnalyzerConfig> {
// Apply rules
const rules = outConfig.rules || {};

const ALL_RULE_IDS = (await litAnalyzer).ALL_RULE_IDS;

ALL_RULE_IDS.forEach(ruleName => {
withConfigValue(config, `rules.${ruleName}`, value => {
rules[ruleName] = value;
Expand Down
2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
useTabs: true,
tabWidth: 2,
singleQuote: false,
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"noImplicitReturns": true,
"outDir": "./lib",

"lib": ["es2023"]
"lib": ["es2023"],

"types": ["node"]
},

"exclude": ["node_modules"]
}
Loading