Skip to content

Commit

Permalink
Added GitHub actions (#14)
Browse files Browse the repository at this point in the history
* Updated README.md

* Added .gitignore

* Added GitHub actions
  • Loading branch information
ping-localhost authored Feb 18, 2025
1 parent 66898da commit b433927
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 74 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Ensure valid code

on:
pull_request:

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3

- name: Run ESLint check
run: npx eslint

- name: Annotate Pull Request with Results
if: failure()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ ESLint found issues.'
})
29 changes: 29 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Ensure valid codestyle

on:
pull_request:

jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3

- name: Run Prettier check
run: npx prettier --check **/*.js

- name: Annotate Pull Request with Results
if: failure()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ Prettier found formatting issues. Please run `npx prettier --write **/*.js` to fix them.'
})
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# IDEs and editors
.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
.sass-cache
connect.lock
typings

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*


# Dependency directories
node_modules/
jspm_packages/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# Lerna
lerna-debug.log

# System Files
.DS_Store
Thumbs.db
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid"
}
94 changes: 47 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,51 @@

[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge)](https://github.com/hacs/integration) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/ping-localhost/seventeen-track-card?style=for-the-badge) ![GitHub Release Date](https://img.shields.io/github/release-date/ping-localhost/seventeen-track-card?style=for-the-badge)

This card gives you a list of shipment information generated by the official [17track.net sensor](https://www.home-assistant.io/components/seventeentrack/).
This card gives you a list of shipment information generated by the official [17track.net sensor](https://www.home-assistant.io/integrations/seventeentrack/).

## Options

| Name | Type | Requirement | Description |
| -------------------- | ------- | ----------- | ----------- |
| type | string | **Required** | `custom:seventeen-track-card` |
| entity | string | **Required** | The entity_id of the sensor you want to show (e.g., `sensor.seventeentrack_packages_in_transit`). |
| title | string | **Optional** | Custom title for the card. Defaults to `17Track.net`. |
| Name | Type | Requirement | Description |
|----------------------|---------|--------------|-----------------------------------------------------------------------------------------------------------------------|
| type | string | **Required** | `custom:seventeen-track-card` |
| entity | string | **Required** | The entity_id of the sensor you want to show (e.g., `sensor.seventeentrack_packages_in_transit`). |
| title | string | **Optional** | Custom title for the card. Defaults to `17Track.net`. |
| sort_order | string | **Optional** | Sort packages by timestamp. Accepts `"ASC"` or `"DESC"` (case-insensitive). If not provided, no sorting is performed. |
| table_padding | string | **Optional** | Table padding for all sides. Provide a single CSS length (e.g., `"15px"`). Defaults to `"32px"`. |
| separator | boolean | **Optional** | Enable row separators between packages. Defaults to `false`. |
| show_title | boolean | **Optional** | Show the Title column. Defaults to `true`. |
| show_status | boolean | **Optional** | Show the Status column. Defaults to `true`. |
| show_location | boolean | **Optional** | Show the Location column. Defaults to `true`. |
| show_last_update | boolean | **Optional** | Show the Last Update column. Defaults to `true`. |
| one_line_last_update | boolean | **Optional** | If `true`, displays the Last Update column with a fixed width style (i.e., one line). Defaults to `false`. |
| table_padding | string | **Optional** | Table padding for all sides. Provide a single CSS length (e.g., `"15px"`). Defaults to `"32px"`. |
| separator | boolean | **Optional** | Enable row separators between packages. Defaults to `false`. |
| show_title | boolean | **Optional** | Show the Title column. Defaults to `true`. |
| show_status | boolean | **Optional** | Show the Status column. Defaults to `true`. |
| show_location | boolean | **Optional** | Show the Location column. Defaults to `true`. |
| show_last_update | boolean | **Optional** | Show the Last Update column. Defaults to `true`. |
| one_line_last_update | boolean | **Optional** | If `true`, displays the Last Update column with a fixed width style (i.e., one line). Defaults to `false`. |

## Manual installation

### Step 1

Install `seventeen-track-card` by copying `seventeen-track-card.js` from this repo to `<config directory>/www/seventeen-track-card.js` on your Home Assistant instance.

**Example:**
---

```bash
wget https://raw.githubusercontent.com/ping-localhost/seventeen-track-card/master/seventeen-track-card.js
mv seventeen-track-card.js /config/www/
```

### Step 2

Link `seventeen-track-card` inside your `ui-lovelace.yaml`.
Add a custom element in your `ui-lovelace.yaml`

```yaml
resources:
- url: /local/seventeen-track-card.js
type: module
- type: custom:seventeen-track-card
entity: sensor.seventeentrack_packages_in_transit
title: "17Track.net" # Default title
sort_order: "" # Options: "ASC" or "DESC". Default is no sorting.
table_padding: "32px" # Default padding for all sides (use a single CSS value)
separator: false # Enable row separators (default: false)
show_title: true # Show the Title column (default: true)
show_status: true # Show the Status column (default: true)
show_location: true # Show the Location column (default: true)
show_last_update: true # Show the Last Update column (default: true)
one_line_last_update: false # Display Last Update in one line (default: false)
```
## HACS installation
### Step 1
Install HACS as per there [Installation guide](https://hacs.xyz/docs/installation/prerequisites).
Install HACS as per there [Installation guide](https://hacs.xyz/docs/use/download/prerequisites/).
### Step 2
Add my repository as a custom repostiory in the HACS settings (and be sure to select the `Plugin` category).
Add my repository as a custom repository in the HACS settings (and be sure to select the `Plugin` category).

### Step 3

Expand All @@ -61,25 +56,30 @@ Install the card as you are used to and set it up as instructed by HACS, which c
type: module
```

### Step 4
## Manual installation

Add a custom element in your `ui-lovelace.yaml`
### Step 1

Install `seventeen-track-card` by copying `seventeen-track-card.js` from this repo to `<config directory>/www/seventeen-track-card.js` on your Home Assistant instance.

**Example:**

```bash
wget https://raw.githubusercontent.com/ping-localhost/seventeen-track-card/master/seventeen-track-card.js
mv seventeen-track-card.js /config/www/
```

### Step 2

Link `seventeen-track-card` inside your `ui-lovelace.yaml`.

```yaml
- type: custom:seventeen-track-card
entity: sensor.seventeentrack_packages_in_transit
title: "17Track.net" # Default title
sort_order: "" # Options: "ASC" or "DESC". Default is no sorting.
table_padding: "32px" # Default padding for all sides (use a single CSS value)
separator: false # Enable row separators (default: false)
show_title: true # Show the Title column (default: true)
show_status: true # Show the Status column (default: true)
show_location: true # Show the Location column (default: true)
show_last_update: true # Show the Last Update column (default: true)
one_line_last_update: false # Display Last Update in one line (default: false)
resources:
- url: /local/seventeen-track-card.js
type: module
```

# Final result
## Final result

![example](example.png)

Expand Down
103 changes: 103 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
export default [
// Global variables
{
languageOptions: {
globals: {
console: true,
customElements: true,
document: true,
HTMLElement: true,
},
},
},

// Global settings
{
files: ['**/*.js'],
settings: {
react: {
// removes warning "React version not specified in eslint-plugin-react settings"
version: 'detect',
},
},
},

// Ground rules
{
// inspired by:
// - https://github.com/eslint/eslint/blob/dd58cd4afa6ced9016c091fc99a702c97a3e44f0/conf/eslint-recommended.js#L14-L74
// - https://github.com/suchipi/eslint-config-unobtrusive/blob/744a7f23a549c3dcf0a35a0d43372a268af4f028/index.js
rules: {
'constructor-super': 'error',
'for-direction': 'error',
'getter-return': 'error',
'no-case-declarations': 'warn',
'no-class-assign': 'warn',
'no-compare-neg-zero': 'warn',
// https://github.com/suchipi/eslint-config-unobtrusive/blob/744a7f23a549c3dcf0a35a0d43372a268af4f028/index.js#L43-L52
'no-cond-assign': ['warn', 'except-parens'],
'no-const-assign': 'error',
// https://github.com/suchipi/eslint-config-unobtrusive/blob/744a7f23a549c3dcf0a35a0d43372a268af4f028/index.js#L58-L63
'no-constant-condition': ['warn', { checkLoops: false }],
'no-debugger': 'warn',
'no-delete-var': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error', // Note: has a TS extension
'no-dupe-else-if': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty-character-class': 'warn',
'no-empty-function': 'warn', // Note: has a TS extension
'no-empty-pattern': 'warn',
'no-ex-assign': 'warn',
'no-func-assign': 'warn',
'no-global-assign': 'error',
'no-import-assign': 'error',
'no-invalid-regexp': 'error',
'no-loss-of-precision': 'warn', // Note: has a TS extension
'no-misleading-character-class': 'warn',
'no-new-native-nonconstructor': 'error',
'no-nonoctal-decimal-escape': 'warn',
'no-obj-calls': 'error',
'no-octal': 'error',
'no-redeclare': 'warn', // Note: has a TS extension
'no-self-assign': 'warn',
'no-setter-return': 'warn',
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'warn',
'no-this-before-super': 'error',
'no-undef': 'error',
'no-unexpected-multiline': 'warn',
'no-unreachable': 'warn',
'no-unsafe-finally': 'warn',
'no-unsafe-negation': 'warn',
'no-unsafe-optional-chaining': 'warn',
// typically represents an unfinished assignment
// https://github.com/facebook/create-react-app/blob/a422bf227cf5294a34d68696664e9568a152fd8f/packages/eslint-config-react-app/index.js#L167-L174
// Note: has a TS extension
'no-unused-expressions': [
'warn',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
},
],
'no-unused-labels': 'warn',
// rest siblings are fine
// https://github.com/facebook/create-react-app/blob/a422bf227cf5294a34d68696664e9568a152fd8f/packages/eslint-config-react-app/index.js#L176-L182
// Note: has a TS extension
'no-unused-vars': ['warn', { args: 'none', ignoreRestSiblings: true }],
// https://github.com/facebook/create-react-app/blob/a422bf227cf5294a34d68696664e9568a152fd8f/packages/eslint-config-react-app/index.js#L183-L190
// Note: has TS extension
'no-use-before-define': ['warn', { functions: false, classes: false, variables: false }],
'no-useless-backreference': 'warn',
'no-useless-escape': 'warn',
'no-with': 'error',
'require-yield': 'warn',
'use-isnan': 'warn',
// https://github.com/suchipi/eslint-config-unobtrusive/blob/744a7f23a549c3dcf0a35a0d43372a268af4f028/index.js#L217-L225
'valid-typeof': ['warn', { requireStringLiterals: false }],
},
},
];
Loading

0 comments on commit b433927

Please sign in to comment.