Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanYadaev committed Aug 15, 2023
1 parent 59de8fb commit 44c9fc7
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 15 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:

env:
PNPM_VERSION: 8.6.3

jobs:
test:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x, 18.x, 19.x, 20.x]
eslint-version: [7, 8]
os: [ubuntu-latest, windows-latest]
fail-fast: false

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}

- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: pnpm

- run: pnpm install

- run: pnpm test:ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
pnpm-lock.yaml
.idea
.idea
dist
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2023 Matan Yadaev

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.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@TODO
62 changes: 59 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
{
"name": "eslint-plugin-testing",
"version": "0.0.0",
"repository": "MatanYadaev/eslint-plugin-testing",
"description": "ESLint plugin for testing",
"keywords": [],
"keywords": [
"testing",
"eslint",
"eslintplugin",
"eslint-plugin",
"eslint-plugin-testing"
],
"homepage": "https://github.com/MatanYadaev/eslint-plugin-testing#readme",
"bugs": {
"url": "https://github.com/MatanYadaev/eslint-plugin-testing/issues"
},
"repository": "MatanYadaev/eslint-plugin-testing",
"license": "MIT",
"author": "Matan Yadaev",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"default": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"lint:eslint-docs": "pnpm build && eslint-doc-generator --check",
"lint:js": "eslint . --fix",
"lint": "concurrently --prefixColors auto \"pnpm:lint:*\"",
"release": "pnpm build && bumpp package.json --commit --push --tag && pnpm publish",
"stub": "unbuild --stub",
"test:ci": "vitest run",
"test": "vitest",
"update:eslint-docs": "pnpm build && eslint-doc-generator"
},
"dependencies": {
"@typescript-eslint/utils": "^6.2.1"
"@typescript-eslint/utils": "^6.4.0"
},
"devDependencies": {
"@tsconfig/node12": "^12.1.0",
"@tsconfig/strictest": "^2.0.1",
"@types/eslint": "^8.44.2",
"@typescript-eslint/parser": "^6.4.0",
"@typescript-eslint/rule-tester": "^6.4.0",
"eslint": "^8.47.0",
"eslint-doc-generator": "^1.4.3",
"eslint-plugin-eslint-plugin": "^5.1.1",
"node12": "link:@@tsconfig/node12",
"typescript": "^5.1.6",
"unbuild": "^1.2.1",
"vitest": "^0.34.1"
},
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=12.0.0"
}
}
9 changes: 3 additions & 6 deletions src/rules/aaa-comments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
import {TSESTree} from "@typescript-eslint/utils";
import {createRule} from "../utils/create-rule";

export const RULE_NAME = 'aaa-comments'
Expand All @@ -16,6 +16,7 @@ const isTestCallExpression = (node: TSESTree.CallExpression) => {
const isOnlyOrSkipCall = node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
testFunctionNames.includes(node.callee.object.name) &&
'name' in node.callee.property &&
['only', 'skip'].includes(node.callee.property.name);

if (isOnlyOrSkipCall) {
Expand All @@ -41,10 +42,6 @@ export default createRule<Options, MessageIds>({

const comments = context.getSourceCode().getCommentsInside(node);

const hasArrangeComment = comments.some((comment) =>
comment.value.trim().toLowerCase().startsWith('arrange')
);

const hasActComment = comments.some((comment) =>
comment.value.trim().toLowerCase().startsWith('act')
);
Expand All @@ -53,7 +50,7 @@ export default createRule<Options, MessageIds>({
comment.value.trim().toLowerCase().startsWith('assert')
);

if (!( hasActComment && hasAssertComment)) {
if (!(hasActComment && hasAssertComment)) {
context.report({
node,
messageId: 'default',
Expand Down
3 changes: 2 additions & 1 deletion src/utils/create-rule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ESLintUtils} from "@typescript-eslint/utils";
import { version } from '../../package.json';

export const createRule = ESLintUtils.RuleCreator(
name => `https://github.com/MatanYadaev/eslint-plugin-testing/blob/main/docs/rules/${name}.md`,
name => `https://github.com/MatanYadaev/eslint-plugin-testing/blob/v${version}/docs/rules/${name}.md`,
);
11 changes: 7 additions & 4 deletions src/utils/rule-tester.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { RuleTester } from "eslint";
import { RuleTester } from '@typescript-eslint/rule-tester'
import { afterAll, describe, it } from 'vitest'

RuleTester.afterAll = afterAll
RuleTester.describe = describe
RuleTester.it = it

export const ruleTester = new RuleTester({
env: {
es6: true,
}
parser: '@typescript-eslint/parser',
});
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["@tsconfig/node12/tsconfig.json", "@tsconfig/strictest/tsconfig.json"],
"compilerOptions": {
"moduleResolution": "nodenext",
"module": "commonjs",
"sourceMap": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
}

0 comments on commit 44c9fc7

Please sign in to comment.