Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ljwagerfield committed Feb 8, 2024
0 parents commit 52521bf
Show file tree
Hide file tree
Showing 16 changed files with 7,148 additions and 0 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node 12
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
93 changes: 93 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# ESLint at project-level as linting settings may differ between browser-based and node-based projects.
# Prettier at repository-level as formatting settings will be the same across all projects.
# IMPORTANT: Sync with all other '.eslintrc.yaml' files!
root: true
parser: "@typescript-eslint/parser"
parserOptions:
project: "./tsconfig.json"
plugins:
- "@typescript-eslint"
rules:
"no-else-return": error
"object-shorthand": error
"@typescript-eslint/no-var-requires": error
"@typescript-eslint/no-redeclare": off
"@typescript-eslint/member-ordering":
- error
- default:
order: alphabetically
memberTypes:
# Index signature
- "signature"

# Fields
- "public-static-field"
- "protected-static-field"
- "private-static-field"

- "public-decorated-field"
- "protected-decorated-field"
- "private-decorated-field"

- "public-instance-field"
- "protected-instance-field"
- "private-instance-field"

- "public-abstract-field"
- "protected-abstract-field"
- "private-abstract-field"

- "public-field"
- "protected-field"
- "private-field"

- "static-field"
- "instance-field"
- "abstract-field"

- "decorated-field"

- "field"

# Constructors
- "public-constructor"
- "protected-constructor"
- "private-constructor"

- "constructor"

# Methods
- "public-static-method"
- "protected-static-method"

- "public-decorated-method"
- "protected-decorated-method"

- "public-instance-method"
- "protected-instance-method"

- "public-abstract-method"
- "protected-abstract-method"

- "public-method"
- "protected-method"

- "private-static-method"
- "private-decorated-method"
- "private-instance-method"
- "private-abstract-method"
- "private-method"

- "static-method"
- "instance-method"
- "abstract-method"

- "decorated-method"

- "method"
extends:
- standard-with-typescript
- prettier
- prettier/@typescript-eslint
env:
node: true
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Continuous Integration

on:
pull_request:
branches: ["*"]
push:
branches: ["*"]

defaults:
run:
shell: bash

jobs:
ci:
name: "Continuous Integration"
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v2
- name: "Install node & npm"
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: "Install dependencies"
run: npm ci
- name: "Linting"
run: npm run lint
- name: "Type checks"
run: npm run typecheck
- name: "Publish"
if: github.ref == 'refs/heads/main'
uses: pascalgn/npm-publish-action@1.3.5
with:
tag_name: "v%s"
tag_message: "v%s"
commit_pattern: "^Release (\\S+)"
workspace: "."
publish_command: "yarn"
publish_args: "--non-interactive"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically generated by GitHub / is not in our secrets.
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: "Notification on success"
if: github.ref == 'refs/heads/main'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: deployments
SLACK_COLOR: "#17BB5E"
SLACK_TITLE: "Built: eslint-plugin-test-groups :rocket:"
SLACK_FOOTER: "This package was successfully built."
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: "Notification on failure"
if: github.ref == 'refs/heads/main' && failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: deployments
SLACK_COLOR: "#BB1717"
SLACK_TITLE: "Failed: eslint-plugin-test-groups :boom:"
SLACK_FOOTER: "No packages published."
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# OSX
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.Spotlight-V100
.Trashes

# Windows
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp

# IntelliJ
.idea/
*.iml

# Node.js
node_modules/
peer_modules/
npm-debug.log*

# NPM Packages
*.tgz
dist/

# Serverless directories
.serverless

# Webpack directories
.webpack

# Standard
tmp/
.tmp/
*.log
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "preserve",
"quoteProps": "consistent",
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Upload Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## ESLint Rule: `require-groups-for-tests`

Requires return types on lambdas that return object literals.

### Installation

```bash
npm install --save-dev eslint-plugin-test-groups
```

**.eslintrc.yaml:**

```yaml
root: true
parser: "@typescript-eslint/parser"
parserOptions:
project: "./tsconfig.json"
plugins:
- "@typescript-eslint"
- "return-types-object-literals" # ← Add this
rules:
# ↓ And this:
"return-types-object-literals/require-groups-for-tests": error
```
### Examples
```typescript
/**
* If the 'group' attribute is not declared, then this ESLint rule will return an error.
*
* Furthermore, the 'group' attribute must match one the configured groups for the rule (you define these).
*
* @group some-test-group
*/
describe("Some Tests", () => {

})
```

### Benefits

Ensures every test is assigned to a group.

Restricting the groups to known values allows you to easily keep your CI pipelines in sync, for example, if you're running tests in parallel and need to list each group individually in your CI config.

### Credits

The following resources were very useful when writing this plugin:

- [Writing custom TypeScript ESLint rules: How I learned to love the AST](https://dev.to/alexgomesdev/writing-custom-typescript-eslint-rules-how-i-learned-to-love-the-ast-15pn)
- [AST Explorer](https://astexplorer.net/)
- Set language 'JavaScript'
- Set parser to '@typescript-eslint/parser'

### License

[MIT](LICENSE)
15 changes: 15 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Releasing

To release a new version:

1. `gco main`

2. Set `x.y.z` into `package.json`

3. `gcmsg 'Release x.y.z'`

4. `gp`

The CI process will automatically `git tag` and `npm publish`.

(It does this by pattern-matching on `^Release (\S+)` commit messages on the `main` branch.)
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const presets = ["@babel/preset-env"];

module.exports = { presets };
Loading

0 comments on commit 52521bf

Please sign in to comment.