Skip to content

Commit

Permalink
Add formatting (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar1jn authored Nov 13, 2023
1 parent 3c7c10a commit aec6f0c
Show file tree
Hide file tree
Showing 15 changed files with 1,443 additions and 17 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Directories
.github
dist
node_modules

# Files
**/*.d.ts
pnpm-lock.yaml
prettier.config.js
63 changes: 63 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/** @type {import("@types/eslint").Linter.Config} */
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
// These off/configured-differently-by-default rules fit well for us
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-shadow': ['error'],

// We do want console statements occasionally (for example, used in error handling)
'no-console': 'off',

// Todo: do we want these?
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-explicit-any': 'off',

// These rules enabled by the preset configs don't work well for us
'@typescript-eslint/await-thenable': 'off',
'prefer-const': 'off',
},
};
15 changes: 15 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Format

on:
workflow_dispatch:
push:
branches:
- main

jobs:
prettier:
if: github.repository_owner == 'withastro'
uses: withastro/automation/.github/workflows/format.yml@main
with:
command: "format:ci"
secrets: inherit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
lib
dist
node_modules
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Directories
.github
dist
node_modules

# Files
**/*.d.ts
pnpm-lock.yaml
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
"private": true,
"version": "1.0.0",
"description": "",
"main": "lib/app.js",
"main": "dist/app.js",
"type": "module",
"scripts": {
"build": "tsc --build --verbose",
"start": "node .",
"dev": "tsc && node .",
"preinstall": "npx only-allow pnpm"
"preinstall": "npx only-allow pnpm",
"lint": "eslint . --report-unused-disable-directives",
"format": "pnpm run format:code",
"format:ci": "pnpm run format:imports && pnpm run format:code",
"format:code": "prettier . -w --cache",
"format:imports": "organize-imports-cli ./tsconfig.json"
},
"engines": {
"node": ">=18.18.0",
Expand All @@ -22,11 +27,18 @@
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"html-entities": "^2.4.0",
"node-schedule": "^2.1.1"
"node-schedule": "^2.1.1",
"organize-imports-cli": "^0.10.0"
},
"devDependencies": {
"@types/node": "^18.17.18",
"@types/node-schedule": "^2.1.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
"license": "MIT"
Expand Down
Loading

0 comments on commit aec6f0c

Please sign in to comment.