Skip to content

Commit

Permalink
♻️ Improve DX, cleanup structure (#94)
Browse files Browse the repository at this point in the history
Resolves #93
  • Loading branch information
mheob committed Sep 5, 2022
1 parent d8205cb commit 57a44ea
Show file tree
Hide file tree
Showing 20 changed files with 1,417 additions and 328 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('eslint').ESLint.ConfigData} */
module.exports = {
root: true,
extends: ['@mheob/eslint-config'],
rules: {
'unicorn/no-array-reduce': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-object-from-entries': 'off',
},
};
14 changes: 0 additions & 14 deletions .eslintrc.json

This file was deleted.

17 changes: 16 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", ":preserveSemverRanges", "group:allNonMajor"],
"assignees": ["mheob"],
"reviewers": ["mheob"],
"labels": ["dependencies"],
"schedule": ["before 3am on Friday"],
"npm": { "stabilityDays": 5 }
"npm": { "stabilityDays": 5 },
"commitMessagePrefix": "⬆️",
"commitMessageAction": "Upgrade",
"packageRules": [
{
"updateTypes": ["pin"],
"commitMessagePrefix": "📌",
"commitMessageAction": "Pin"
},
{
"updateTypes": ["rollback"],
"commitMessagePrefix": "⬇️",
"commitMessageAction": "Downgrade"
}
]
}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
*.vsix

snippets

node_modules/
node_modules
13 changes: 13 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('prettier').Config} */
module.exports = {
...require('@mheob/prettier-config'),
overrides: [
{
files: ['*.md'],
options: {
parser: 'markdown',
printWidth: 999,
},
},
],
};
14 changes: 0 additions & 14 deletions .prettierrc.json

This file was deleted.

11 changes: 1 addition & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,5 @@
"default": true,
"MD024": false,
"MD033": false
},
// Yarn berry
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": ".yarn/sdks/typescript/lib"
}
}
12 changes: 0 additions & 12 deletions .whitesource

This file was deleted.

67 changes: 32 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,34 @@ export default MyDynamicComponentName

### Common

| Trigger | Content | Only for languages |
| :------- | :---------------------------------------- | :----------------- |
| `dtid⇥` | adds `data-testid="…"` | `.jsx`, `.tsx` |
| `forIn⇥` | for ... in loop `for(const … in …) { … }` | |
| `forOf⇥` | for ... of loop `for(const … of …) { … }` | |
| Trigger | Content | Only for languages |
| :------ | :--------------------- | :----------------- |
| `dtid⇥` | adds `data-testid="…"` | `.jsx`, `.tsx` |

### Console

| Trigger | Content |
| :-------------- | :------------------------------- |
| `consoleError` | console error `console.error(…)` |
| `consoleInfo` | console info `console.info(…)` |
| `consoleLog` | console log `console.log(…)` |
| `consoleWarn` | console warn `console.warn(…)` |
| Trigger | Content |
| :----------- | :------------------------------- |
| `consError` | console error `console.error(…)` |
| `consInfo` | console info `console.info(…)` |
| `consLog` | console log `console.log(…)` |
| `consWarn` | console warn `console.warn(…)` |

### Export and Import

| Trigger | Content | Only for languages |
| :-------------------- | :-------------------------------------------------------------- | :----------------- |
| `exportAllFrom` | exports all from module `export * from '…'` | |
| `exportAs` | exports all as alias from module `export … as … from '…'` | |
| `exportConst` | exports const `export const … = …` | |
| `exportDefault⇥` | exports default `export default …` | |
| `importFrom` | imports entire module `import … from '…'` | |
| `importAllFrom` | imports all as alias from module `import … as … from '…'` | |
| `importDestructured` | imports only destructed part of module `import { … } from '…'` | |
| `importFileOnly` | imports entire module without module name `import '…'` | |
| `importReact` | import the `React` module `import React from 'react'` | `.jsx`, `.tsx` |
| `importReactDom` | import the `ReactDOM` module `import ReactDOM from 'react-dom'` | `.jsx`, `.tsx` |
| `importType` | import only the type from module `import type { … } from '…'` | `.ts`, `.tsx` |
| Trigger | Content | Only for languages |
| :----------------- | :-------------------------------------------------------------- | :----------------- |
| `expAllFrom` | exports all from module `export * from '…'` | |
| `expAs` | exports all as alias from module `export … as … from '…'` | |
| `expConst` | exports const `export const … = …` | |
| `exportDefault⇥` | exports default `export default …` | |
| `impFrom` | imports entire module `import … from '…'` | |
| `impAllFrom` | imports all as alias from module `import … as … from '…'` | |
| `impDestructured` | imports only destructed part of module `import { … } from '…'` | |
| `impFileOnly` | imports entire module without module name `import '…'` | |
| `impReact` | import the `React` module `import React from 'react'` | `.jsx`, `.tsx` |
| `impReactDom` | import the `ReactDOM` module `import ReactDOM from 'react-dom'` | `.jsx`, `.tsx` |
| `impType` | import only the type from module `import type { … } from '…'` | `.ts`, `.tsx` |

### Functions

Expand All @@ -87,17 +85,16 @@ export default MyDynamicComponentName

### React Hooks

| Trigger | Hook |
| :---------------- | :--------------------------------------------------------------------------------- |
| `useCallback⇥` | create `useCallback` hook |
| `useContext⇥` | create `useContext` hook |
| `useEffect⇥` | create `useEffect` hook |
| `useMemo⇥` | create `useMemo` hook |
| `useReducer⇥` | create `useReducer` hook |
| `useRef⇥` | create `useRef` hook |
| `useRouter⇥` | create `useRouter` hook |
| `useState⇥` | create `useState` hook |
| `useTranslation⇥` | create `useTranslation` hook (part of [react.i18next](https://react.i18next.com/)) |
| Trigger | Hook |
| :------------- | :------------------------ |
| `useCallback⇥` | create `useCallback` hook |
| `useContext⇥` | create `useContext` hook |
| `useEffect⇥` | create `useEffect` hook |
| `useMemo⇥` | create `useMemo` hook |
| `useReducer⇥` | create `useReducer` hook |
| `useRef⇥` | create `useRef` hook |
| `useRouter⇥` | create `useRouter` hook |
| `useState⇥` | create `useState` hook |

## Snippets List for Markdown

Expand Down
37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-snippets",
"displayName": "Snippets for Next.js, React in TypeScript",
"version": "1.3.0",
"version": "2.0.0",
"private": true,
"description": "Snippets for the development with Next.js, React in a TypeScript environment.",
"categories": [
Expand All @@ -25,12 +25,12 @@
"license": "MIT",
"publisher": "mheob",
"scripts": {
"build": "pnpm clean && ts-node scripts/generate-snippet-files.ts",
"build": "pnpm clean && ts-node scripts/generateSnippetFiles.ts",
"clean": "rimraf snippets",
"deploy": "pnpm build && vsce package --no-dependencies",
"deploy": "pnpm build && pnpm exec vsce package --no-dependencies",
"format": "prettier --write **/*.{ts,json,md,yml} --ignore-path .gitignore",
"prepare": "husky install",
"lint": "eslint . --ext .ts",
"prepare": "husky install",
"vscode:prepublish": "pnpm build"
},
"contributes": {
Expand Down Expand Up @@ -63,24 +63,25 @@
"package.json": "pnpm dlx sort-package-json"
},
"devDependencies": {
"@types/node": "^17.0.35",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-unicorn": "^43.0.0",
"@mheob/eslint-config": "^2.1.0",
"@mheob/prettier-config": "^1.4.0",
"@types/node": "^18.7.14",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"eslint": "^8.23.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.0",
"prettier": "^2.6.2",
"prettier-plugin-jsdoc": "^0.4.0",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"ts-node": "^10.8.0",
"typescript": "^4.7.2",
"vsce": "^2.8.0"
"ts-node": "^10.9.1",
"typescript": "^4.8.2",
"vsce": "^2.11.0"
},
"engines": {
"vscode": "^1.65.0"
},
"icon": "images/logo.png"
"icon": "images/logo.png",
"sponsor": {
"url": "https://github.com/sponsors/mheob"
}
}
Loading

0 comments on commit 57a44ea

Please sign in to comment.