Skip to content

Instantly share code, notes, and snippets.

View 43081j's full-sized avatar
💭
Diving into repos I don't know

James Garbutt 43081j

💭
Diving into repos I don't know
View GitHub Profile
@43081j
43081j / eslint-8.mjs
Last active August 4, 2025 20:23
ESLint 8 vs 9 config
import depend from 'eslint-plugin-depend';
export default [
{
plugins: {
'depend': depend
},
},
{
...depend.configs['flat/recommended']
@43081j
43081j / OUTPUT
Last active July 25, 2025 19:03
sveltekit type fudgery
export function getFoo(): FooType<NonExistentType> | null;
import type { FooType } from './foo.d.ts';
{
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.name='require']",
"message": "require calls should be replaced with import syntax"
},
{
"selector": "CallExpression[callee.name='createRequire']",
@43081j
43081j / sg.vim
Created April 22, 2025 16:22
ast-grep on current vim buffer
function! RunAstGrepOnBuffer()
let l:input = input('sg/')
if l:input == ''
echo "No input provided"
return
endif
let l:parts = split(l:input, '/')
if len(l:parts) != 2
echoerr "Invalid input format. Expected 'searchPattern/replacePattern'"
return
@43081j
43081j / .vimrc
Last active January 5, 2025 11:44
fzf.vim + ast-grep hackery
command! -bang -nargs=* FzfSg call fzf#vim#sgrep("sg run --heading=never --color=always --pattern=".fzf#shellescape(<q-args>)." | awk -F ':' '!seen[$1]++', fzf#vim#with_preview(), <bang>0)
nnoremap <silent> <leader>sg :execute 'FzfSg ' . input('sg/')<CR>
@43081j
43081j / .mocharc.json
Last active January 21, 2025 18:41
mocha 10 + chai 5 + ts-node
{
"loader": "ts-node/esm",
"extensions": ["ts"],
"spec": [
"tests/*.ts"
]
}
@43081j
43081j / .eslintrc.json
Created June 28, 2021 07:29
Disallow `it.only` via ESLint
{
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.type='Identifier'][callee.object.name='it'][callee.property.type='Identifier'][callee.property.name='only']",
"message": "it.only is only allowed during development"
}
]
}
import { Component, Prop } from '@stencil/core';
@Component({
tag: 'x-foo',
shadow: true
})
export class XFoo {
@Prop()
public flag: string = 'foo';
@43081j
43081j / karma.conf.js
Created August 23, 2017 14:16
Polymer + Webpack + Karma config
const webpackConfig = require('./webpack.config.js');
const webpack = require('webpack');
const path = require('path');
delete webpackConfig.entry;
webpackConfig.bail = false;
webpackConfig.stats = 'errors-only';
webpackConfig.plugins.push(new webpack.SourceMapDevToolPlugin({
filename: null,
test: /\.(ts|js)($|\?)/i