Skip to content

Commit

Permalink
chore: boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jun 28, 2022
1 parent 0fd048e commit 6bf74cc
Show file tree
Hide file tree
Showing 15 changed files with 4,923 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = tab
indent_size = 4

# tab indentation by default
[*.{js,jsx,ts,tsx}]
indent_style = tab
indent_size = 4

# space indentation for some specific files
[package.json]
indent_style = space
indent_size = 2

[io-package.json]
indent_style = space
indent_size = 4

[*.{yml,yaml,md}]
indent_style = space
indent_size = 2

[config/**/*.json]
indent_style = tab
indent_size = 4

# Indent code blocks in the documentation with 4-size tabs
[docs/**/*.md]
indent_style = tab
indent_size = 4
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
node_modules/
**/node_modules/
.*
141 changes: 141 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
Note to future self:
If ESLint is ever extremely slow again, check if there are .js and/or .map files in the source directories
and delete them:
```bash
find . -type f -name "*.map" | grep ./packages | grep /src/ | xargs -n1 rm
find . -type f -name "*.js" | grep ./packages | grep /src/ | xargs -n1 rm
```
Running `TIMING=1 DEBUG=eslint:cli-engine yarn run lint:ts` helps detect the problem
*/

module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2021, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
project: "./tsconfig.json",
},
extends: [
// Use the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
// Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
"plugin:prettier/recommended",
],
plugins: [],
reportUnusedDisableDirectives: true,
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-use-before-define": [
"error",
{
functions: false,
typedefs: false,
classes: false,
},
],
"@typescript-eslint/no-unused-vars": [
"error",
{
ignoreRestSiblings: true,
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-non-null-assertion": "off", // This is necessary for Map.has()/get()!
"@typescript-eslint/no-inferrable-types": [
"error",
{
ignoreProperties: true,
ignoreParameters: true,
},
],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": false,
"ts-ignore": true,
"ts-nocheck": true,
"ts-check": false,
},
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
allowBoolean: true,
// This is necessary to log errors
// TODO: Consider switching to false when we may annotate catch clauses
allowAny: true,
allowNullish: true,
},
],
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false,
},
],
// We can turn this on from time to time but in general these rules
// make our lives harder instead of easier
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",

// Although this rule makes sense, it takes about a second to execute (and we don't need it)
"@typescript-eslint/no-implied-eval": "off",

"@typescript-eslint/explicit-module-boundary-types": [
"warn",
{ allowArgumentsExplicitlyTypedAsAny: true },
],
"@typescript-eslint/no-this-alias": "off",

// Prefer simple property access and declaration without quotes
"dot-notation": "off",
"@typescript-eslint/dot-notation": [
"error",
{
allowPrivateClassPropertyAccess: true,
allowProtectedClassPropertyAccess: true,
},
],
"quote-props": ["error", "as-needed"],
},
overrides: [
{
files: ["*.test.ts"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-member-return": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/dot-notation": "off",
},
},
{
files: ["*.js"],
rules: {
"@typescript-eslint/*": "off",
},
},
],
};
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules/

# Yarn config and stuff - we're not using Zero-Installs
# because that would blow up the repo size even more
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# Compiled source files
**/build
**/*.tsbuildinfo
*.map

.secrets
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CHANGELOG*.md
package.json
package-lock.json
build/
.github/workflows/
.github/actions/**/*.yml
cache/
28 changes: 28 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: false,
printWidth: 80,
useTabs: true,
tabWidth: 4,
endOfLine: "lf",

plugins: [require("prettier-plugin-organize-imports")],

overrides: [
{
files: "packages/config/**/*.json",
options: {
printWidth: 120,
},
},
{
files: "*.yml",
options: {
useTabs: false,
tabWidth: 2,
singleQuote: true,
},
},
],
};
546 changes: 546 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
enableGlobalCache: true

nodeLinker: pnpm

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

preferInteractive: true

yarnPath: .yarn/releases/yarn-3.2.1.cjs
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@zwave-js/firmware-updates",
"version": "0.0.1",
"description": "The firmware update service for Z-Wave JS",
"main": "build/server.js",
"repository": "https://github.com/zwave-js/firmware-updates",
"author": "Dominic Griesel <[email protected]>",
"license": "MIT",
"scripts": {
"build": "tsc --verbose",
"clean": "tsc --clean",
"watch": "yarn run build --watch --pretty",
"lint": "eslint .",
"dev": "nodemon src/server.ts",
"start": "node build/server.js"
},
"devDependencies": {
"@tsconfig/node16": "^1.0.3",
"@types/eslint": "^8",
"@types/node": "^18.0.0",
"@types/prettier": "^2",
"@types/source-map-support": "^0.5.4",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.1.0",
"fastify": "^4.2.0",
"nodemon": "^2.0.18",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.0.0",
"ts-node": "^10.8.1",
"typescript": "~4.7.4"
},
"packageManager": "[email protected]"
}
19 changes: 19 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fastifyLib from "fastify";

const fastify = fastifyLib({ logger: true });

// Declare a route
fastify.get("/", async (request, reply) => {
return { hello: "world!" };
});

// Run the server!
async function start() {
try {
await fastify.listen({ port: 3000 });
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
}
void start();
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"importsNotUsedAsValues": "error",
"pretty": true,
},
"include": ["src/**/*.ts"]
}
Loading

0 comments on commit 6bf74cc

Please sign in to comment.