Skip to content

Instantly share code, notes, and snippets.

天 夏 on 03-Jul-2024:

Rating: 1/5

When using the official plugin, there is a high probability that the plugin will report errors, causing the editor to fail to recognize files, not to display reminders, text color errors, and plugin crashes. This greatly affects the user experience and is far inferior to the previous Volar plugin. 报错,崩溃,报错,崩溃,可以把Volar搞回来吗?


:Roger! () ⇒ ▼ on 28-Jun-2024:
import type { Rule } from '@tsslint/config';
export function create(): Rule {
return ({ typescript: ts, sourceFile, reportWarning }) => {
ts.forEachChild(sourceFile, function cb(node) {
if (
ts.isCallExpression(node) &&
ts.isIdentifier(node.expression) &&
node.expression.text === 'alert'
) {
import type { Rule } from '@tsslint/config';
export function create(): Rule {
return ({ typescript: ts, sourceFile, languageService, reportWarning }) => {
ts.forEachChild(sourceFile, function walk(node) {
if (ts.isNonNullExpression(node)) {
const typeChecker = languageService.getProgram()!.getTypeChecker();
const type = typeChecker.getTypeAtLocation(node.expression);
if (
typeChecker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation)
/**
*
* @type {import('@tsslint/config').Rule}
*/
const noConsoleRule = ({ typescript: ts, sourceFile, reportWarning }) => {
ts.forEachChild(sourceFile, function walk(node) {
if (
ts.isPropertyAccessExpression(node) &&
ts.isIdentifier(node.expression) &&
node.expression.text === 'console'
@johnsoncodehk
johnsoncodehk / cheapComputed.ts
Last active August 27, 2020 23:16
Vue 3 "cheap" computed
import { computed, ref } from "vue";
import { ComputedGetter, pauseTracking, resetTracking } from "@vue/reactivity";
// if no version, not work for objects/arrays...
export function cheapComputed<T, K = T>(getValue: ComputedGetter<T>, getVersion?: ComputedGetter<K>) {
const value = computed(getValue);
const version = getVersion ? computed(getVersion) : value;
const lastValue = ref<T>();
const lastVersion = ref<K>();
const changed = computed(() => version.value !== lastVersion.value);
@johnsoncodehk
johnsoncodehk / trim-trailing-slash.js
Last active November 16, 2019 17:20
Remove URL trailing slash
window.history.replaceState("", "", window.location.href.replace(new RegExp("/(?!.*/)"), ""))
@johnsoncodehk
johnsoncodehk / Unity.gitignore
Created December 1, 2018 21:09
.gitignore for Unity
/*
/*/
!/Assets/
!/Packages/
!/ProjectSettings/
!.gitignore
del /s /q /f /a .DS_STORE
del /s /q /f /a ._*
del /s /q /f /a *DS_STORE
pause
@johnsoncodehk
johnsoncodehk / AspectRatioFitter.js
Created August 20, 2018 07:11
AspectRatioFitter for CocosCreator
let AspectMode = cc.Enum({
None: 0,
WidthControlsHeight: 1,
HeightControlsWidth: 2,
FitInParent: 3,
EnvelopeParent: 4,
});
cc.Class({
extends: cc.Component,
@johnsoncodehk
johnsoncodehk / CreateScriptAsset.cs
Last active January 18, 2024 10:00
Create script from template in project
// Not support of 2019.1.0f1
static void CreateScriptAsset(string templatePath, string destName) {
#if UNITY_2019_1_OR_NEWER
UnityEditor.ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, destName);
#else
typeof(UnityEditor.ProjectWindowUtil)
.GetMethod("CreateScriptAsset", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
.Invoke(null, new object[] { templatePath, destName });
#endif