Skip to content

Commit

Permalink
Types & serialization (#32)
Browse files Browse the repository at this point in the history
* select

* datetime types

* serialize datetime

* working on serialize

* serialization test coverage

* event test

* date improvements

* lint

* adding validate

* simplify

* lint

* sensor types

* coverage

* test fixes

* exit on fail

* more badges!

* upgrades

* config spec

* test fixes

* lint

* good to go

* rm
  • Loading branch information
Zoe authored Sep 25, 2024
1 parent 40bc5e1 commit 36516d8
Show file tree
Hide file tree
Showing 53 changed files with 4,985 additions and 3,219 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

122 changes: 0 additions & 122 deletions .eslintrc.json

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[![codecov](https://codecov.io/github/Digital-Alchemy-TS/synapse/graph/badge.svg?token=IBGLY3RY68)](https://codecov.io/github/Digital-Alchemy-TS/synapse)
[![stars](https://img.shields.io/github/stars/Digital-Alchemy-TS/synapse)](https://github.com/Digital-Alchemy-TS/synapse)
![discord](https://img.shields.io/discord/1219758743848489147?label=Discord&logo=discord)

[![codecov](https://codecov.io/github/Digital-Alchemy-TS/synapse/graph/badge.svg?token=IBGLY3RY68)](https://codecov.io/github/Digital-Alchemy-TS/synapse)
[![version](https://img.shields.io/github/package-json/version/Digital-Alchemy-TS/synapse)](https://www.npmjs.com/package/@digital-alchemy/synapse)
---

## 📘 Description
Expand All @@ -9,7 +12,6 @@ Welcome to `@digital-alchemy/synapse`!
This project builds on the functions provided by `@digital-alchemy/hass` to provide the ability to generate entities within your Home Assistant install. With the help of a [custom component](https://github.com/Digital-Alchemy-TS/synapse-extension), you can gate logic behind switches, report states with sensors, attach functions to buttons, and more!

- [Extended docs](https://docs.digital-alchemy.app)
- [Discord](https://discord.gg/JkZ35Gv97Y)

## 💾 Install

Expand Down
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ words:
- tvshow
- utcnow
- zeroconf
- unserialize
- cobertura
- entitylocals
- autoincrement
Expand Down
167 changes: 167 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import importPlugin from "eslint-plugin-import";
import jsonc from "eslint-plugin-jsonc";
import noUnsanitized from "eslint-plugin-no-unsanitized";
import sonarjs from "eslint-plugin-sonarjs";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import sortKeysFix from "eslint-plugin-sort-keys-fix";
import unicorn from "eslint-plugin-unicorn";
import prettier from "eslint-plugin-prettier";
import { fixupPluginRules } from "@eslint/compat";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
sonarjs.configs.recommended,
{
plugins: {
import: fixupPluginRules(importPlugin),
jsonc,
"no-unsanitized": noUnsanitized,
"simple-import-sort": simpleImportSort,
"sort-keys-fix": sortKeysFix,
unicorn,
prettier,
},
languageOptions: {
globals: { ...globals.node },
},
},
...compat
.extends(
"plugin:@typescript-eslint/recommended",
"plugin:jsonc/recommended-with-jsonc",
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
"plugin:@cspell/recommended",
)
.map(config => ({ ...config, files: ["src/**/*.ts"] })),
{
files: ["src/**/*.ts"],
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"prettier/prettier": "error",
"unicorn/switch-case-braces": "off",
"unicorn/prefer-module": "off",
"@typescript-eslint/no-magic-numbers": "warn",
"unicorn/no-object-as-default-parameter": "off",
"unicorn/no-null": "off",
"unicorn/no-empty-file": "off",
"sonarjs/prefer-single-boolean-return": "off",
"unicorn/no-array-callback-reference": "off",
"sonarjs/prefer-nullish-coalescing": "off",
"sonarjs/hashing": "off",
"unicorn/no-process-exit": "off",
"sonarjs/function-return-type": "off",
"unicorn/no-await-expression-member": "off",
"sonarjs/no-invalid-await": "off",
"sonarjs/no-nested-functions": "off",
"unicorn/no-useless-undefined": "off",
"@typescript-eslint/unbound-method": "error",
"sonarjs/sonar-no-fallthrough": "off",
"import/no-extraneous-dependencies": [
"error",
{
"packageDir": "./"
}
],
"sonarjs/prefer-immediate-return": "off",
"unicorn/prevent-abbreviations": [
"error",
{
"replacements": {
"docs": false,
"e": false,
"dir": false,
"i": false,
"params": false,
"fn": false,
"props": false,
"ref": false,
"temp": false
}
}
],
"no-case-declarations": "off",
"no-async-promise-executor": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/no-array-for-each": "off",
"sonarjs/no-clear-text-protocols": "off",
"unicorn/import-style": "off",
"sonarjs/fixme-tag": "off",
"sort-keys-fix/sort-keys-fix": "warn",
"unicorn/prefer-event-target": "off",
"simple-import-sort/imports": "warn",
"sonarjs/no-misused-promises": "off",
"sonarjs/no-commented-code": "off",
"@typescript-eslint/no-empty-object-type": "off",
"sonarjs/todo-tag": "off",
"simple-import-sort/exports": "warn",
"no-console": [
"error"
],
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"varsIgnorePattern": "_|logger"
}
],
"@typescript-eslint/no-explicit-any": "error"
}
},
// module definitions
{
files: ["src/**/*.module.ts"],
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"@typescript-eslint/no-magic-numbers": "off",
},
},
{
files: ["src/**/*.spec.ts"],
languageOptions: {
globals: { ...globals.jest },
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"@cspell/spellchecker": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/unbound-method": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-unused-collection": "warn",
"sonarjs/prefer-promise-shorthand": "off",
"unicorn/consistent-function-scoping": "off",
},
},
];
Loading

0 comments on commit 36516d8

Please sign in to comment.