Skip to content

Commit

Permalink
chore: update ts eslint prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 5, 2024
1 parent e75d0e4 commit 4fd09ff
Show file tree
Hide file tree
Showing 15 changed files with 1,122 additions and 68 deletions.
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.experimental.useFlatConfig": true
}
54 changes: 54 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import process from "node:process"
import ts from "@typescript-eslint/eslint-plugin"
import tsParser from "@typescript-eslint/parser"
import eslintConfigPrettier from "eslint-config-prettier"

const files = ["src/**/*.ts"]
const languageOptions = {
parser: tsParser,
parserOptions: {
project: true,
tsconfigRootDir: process.cwd(),
},
}
const linterOptions = {
reportUnusedDisableDirectives: true,
}
const plugins = {
"@typescript-eslint": ts,
}

export default [
// don't lint js files
{
ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"],
},
{
files,
languageOptions,
linterOptions,
plugins,
rules: {
...ts.configs["eslint-recommended"].overrides[0].rules,
...ts.configs["recommended"].rules,
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],

"@typescript-eslint/no-non-null-assertion": "off",

"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",

"no-console": ["warn", { allow: ["warn", "error"] }],
},
},
// disable formatting rules, make sure to put this last
eslintConfigPrettier,
]
2 changes: 1 addition & 1 deletion example/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"plugins": ["prettier-plugin-tailwindcss"]
}
}
6 changes: 2 additions & 4 deletions gen-types.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// @ts-check
import { createRequire } from "module"
import fs from "fs"
import { createRequire } from "module"

const req = createRequire(import.meta.url)
const collections = req("@iconify/json/collections.json")

fs.writeFileSync(
"types.ts",
`export const availableCollectionNames = [${Object.keys(
collections,
)
`export const availableCollectionNames = [${Object.keys(collections)
.map((v) => JSON.stringify(v))
.join(", ")}] as const
/** All the available icon collections when you have \`@iconify/json\` installed */\nexport type CollectionNames = typeof availableCollectionNames[number]
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"publishConfig": {
"access": "public"
},
"type": "module",
"files": [
"dist"
],
Expand All @@ -27,13 +28,17 @@
"license": "MIT",
"packageManager": "pnpm@8.14.0",
"devDependencies": {
"@egoist/prettier-config": "1.0.0",
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@iconify-json/heroicons": "^1.1.19",
"@iconify/json": "^2.2.164",
"@iconify/types": "^2.0.0",
"@types/node": "^18.19.4",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"postcss": "^8.4.33",
"prettier": "3.0.3",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.10",
"tailwindcss": "^3.4.0",
"tsup": "^8.0.1",
Expand Down
Loading

0 comments on commit 4fd09ff

Please sign in to comment.