initial commit of actions

This commit is contained in:
Dominik Polakovics Polakovics 2026-01-31 18:56:04 +01:00
commit 949ece5785
44660 changed files with 12034344 additions and 0 deletions

View file

@ -0,0 +1,67 @@
# v3.0.0
## Added
* Block scope matchers can accept a trailing `*` to optionally match blocks by prefix #35
## Breaking
* Block matchers no longer match prefixes of blocks by default, can now be configured via options #35
# v2.6.0
* Disable auto fixing by default, allow it to be optionally enabled. #26
# v2.5.0
* Add support for auto fixing violations - #19 @tgreen7
# v2.4.0
* Add support for defining 2 levels deep in blocks (ie. `ava.default`)
# v2.3.1
* Bump js-yaml from 3.13.0 to 3.13.1 due to security vulnerability - #11
# v2.3.0
* Allow test block names to be specified in options - #10
# v2.2.0
* Added rule for catching `.only` blocks for `serial` - #9 @IevgenRagulin
# v2.1.0
* Added rule for catching `.only` blocks for `fixture` - #8 @roughy
# v2.0.1
* Fixed major bug where rule would cause errors for objects with key `only` - #7 @bendemboski
# v2.0.0
* Updated rule format to ESLint 3
* Updated ESLInt dependency to `>=3.0.0`
* Updated node engine to `>=4.0.0`
* Get CircleCI up and running
# v1.2.0
* Added rules for catching `.only` blocks for `test`, `context` and `tape`
# v1.1.0
* Updated rule to use `Identifier` rather than `CallExpression`
* Changed reporter to give a more generic message (removed reference to mocha)
* Added additional test coverage
# v1.0.1
* Added additional test coverage
* Removed unnecessary dependencies in `package.json`
# v1.0.0
* Initial version

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Levi Buzolic
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.

View file

@ -0,0 +1,72 @@
# eslint-plugin-no-only-tests
[![Version](https://img.shields.io/npm/v/eslint-plugin-no-only-tests.svg)](https://www.npmjs.com/package/eslint-plugin-no-only-tests) [![Downloads](https://img.shields.io/npm/dm/eslint-plugin-no-only-tests.svg)](https://npmcharts.com/compare/eslint-plugin-no-only-tests?minimal=true) [![GitHub Tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests/workflows/Tests/badge.svg)](https://github.com/levibuzolic/eslint-plugin-no-only-tests/actions?query=workflow%3ATests)
ESLint rule for `.only` tests in [mocha](https://mochajs.org/), [jest](https://jestjs.io/), [jasmine](https://jasmine.github.io/), [Mocha Cakes 2](https://github.com/iensu/mocha-cakes-2) and other JS testing libraries.
By default the following test blocks are matched by default: `describe`, `it`, `context`, `tape`, `test`, `fixture`, `serial`.
Designed to prevent you from committing focused (`.only`) tests to CI, which may prevent your entire test suite from running.
If the testing framework you use doesn't use `.only` to focus tests, you can override the matchers with [options](#options).
## Installation
[Install ESLint](https://eslint.org/docs/user-guide/getting-started) if you haven't done so already, then install `eslint-plugin-no-only-tests`:
```bash
npm install --save-dev eslint-plugin-no-only-tests
# or
yarn add --dev eslint-plugin-no-only-tests
```
> **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-no-only-tests` globally.
## Usage
Add `no-only-tests` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
"plugins": [
"no-only-tests"
]
```
Then add the rule to the rules section of your `.eslintrc`:
```json
"rules": {
"no-only-tests/no-only-tests": "error"
}
```
If you use a testing framework that uses a test block name that isn't present in the [defaults](#options), or a different way of focusing test (something other than `.only`) you can specify an array of blocks and focus methods to match in the options.
```json
"rules": {
"no-only-tests/no-only-tests": [
"error", {
"block": ["test", "it", "assert"],
"focus": ["only", "focus"]
}
]
}
```
The above example will catch any uses of `test.only`, `test.focus`, `it.only`, `it.focus`, `assert.only` and `assert.focus`.
This rule supports opt-in autofixing when the `fix` option is set to `true` to avoid changing runtime code unintentionally when configured in an editor.
```json
"rules": {
"no-only-tests/no-only-tests": ["error", {"fix": true}]
}
```
## Options
Option | Type | Description
---|---|---
`block` | `string[]` | Specify the block names that your testing framework uses. Add a `*` to the end of any string to enable prefix matching (ie. `test*` will match `testExample.only`)<br>Defaults to `["describe", "it", "context", "test", "tape", "fixture", "serial", "Feature", "Scenario", "Given", "And", "When", "Then"]`
`focus` | `string[]` | Specify the focus scope that your testing framework uses.<br>Defaults to `["only"]`
`fix` | `boolean` | Enable this rule to auto-fix violations, useful for a pre-commit hook, not recommended for users with auto-fixing enabled in their editor.<br>Defaults to `false`

View file

@ -0,0 +1,7 @@
'use strict';
module.exports = {
rules: {
'no-only-tests': require('./rules/no-only-tests')
}
};

View file

@ -0,0 +1,40 @@
{
"name": "eslint-plugin-no-only-tests",
"version": "3.1.0",
"description": "ESLint rule for .only blocks in mocha tests",
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin",
"mocha",
"rule",
"only",
"describe",
"it",
"fixture"
],
"author": "Levi Buzolic",
"main": "index.js",
"files": [
"index.js",
"rules/"
],
"scripts": {
"test": "node tests.js"
},
"devDependencies": {
"eslint": ">=3.0.0"
},
"engines": {
"node": ">=5.0.0"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git@github.com:levibuzolic/eslint-plugin-no-only-tests.git"
},
"bugs": {
"url": "https://github.com/levibuzolic/no-only-tests/issues"
},
"homepage": "https://github.com/levibuzolic/no-only-tests#readme"
}

View file

@ -0,0 +1,97 @@
/**
* @fileoverview Rule to flag use of .only in tests, preventing focused tests being committed accidentally
* @author Levi Buzolic
*/
'use strict';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
const defaultOptions = {
block: ['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'Feature', 'Scenario', 'Given', 'And', 'When', 'Then'],
focus: ['only'],
fix: false,
};
module.exports = {
meta: {
docs: {
description: 'disallow .only blocks in tests',
category: 'Possible Errors',
recommended: true,
url: 'https://github.com/levibuzolic/eslint-plugin-no-only-tests',
},
fixable: true,
schema: [
{
type: 'object',
properties: {
block: {
type: 'array',
items: {
type: 'string',
},
uniqueItems: true,
default: defaultOptions.block,
},
focus: {
type: 'array',
items: {
type: 'string',
},
uniqueItems: true,
default: defaultOptions.focus,
},
fix: {
type: 'boolean',
default: defaultOptions.fix,
},
},
additionalProperties: false,
},
],
},
create(context) {
const options = Object.assign({}, defaultOptions, context.options[0]);
const blocks = options.block || [];
const focus = options.focus || [];
const fix = !!options.fix;
return {
Identifier(node) {
const parentObject = node.parent && node.parent.object;
if (parentObject == null) return;
if (focus.indexOf(node.name) === -1) return;
const callPath = getCallPath(node.parent).join('.');
// comparison guarantees that matching is done with the beginning of call path
if (
blocks.find(block => {
// Allow wildcard tail matching of blocks when ending in a `*`
if (block.endsWith('*')) return callPath.startsWith(block.replace(/\*$/, ''));
return callPath.startsWith(`${block}.`);
})
) {
context.report({
node,
message: callPath + ' not permitted',
fix: fix ? fixer => fixer.removeRange([node.range[0] - 1, node.range[1]]) : undefined,
});
}
},
};
},
};
function getCallPath(node, path = []) {
if (node) {
const nodeName = node.name || (node.property && node.property.name);
if (node.object) return getCallPath(node.object, [nodeName, ...path]);
if (node.callee) return getCallPath(node.callee, path);
return [nodeName, ...path];
}
return path;
}