Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-jest-formatting

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jest-formatting - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

1

lib/ast-utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPaddingLineSequences = exports.getActualLastToken = exports.isValidParent = exports.areTokensOnSameLine = exports.isTokenASemicolon = void 0;
exports.isTokenASemicolon = (token) => token.value === ';' && token.type === 'Punctuator';

@@ -4,0 +5,0 @@ exports.areTokensOnSameLine = (left, right) => left.loc.end.line === right.loc.start.line;

78

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configs = exports.rules = void 0;
const padding_1 = require("./rules/padding");

@@ -123,78 +124,3 @@ const paddingConfigs = {

'padding-around-test-blocks': padding_1.createRule(paddingConfigs.test),
'padding-around-all': padding_1.createRule([].concat(...Object.keys(paddingConfigs).map(k => paddingConfigs[k]))),
'padding-before-after-all-blocks': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: 1,
},
], true),
'padding-before-after-each-blocks': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: 2,
},
], true),
'padding-before-before-all-blocks': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: 3,
},
], true),
'padding-before-before-each-blocks': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: 4,
},
], true),
'padding-before-describe-blocks': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: 5,
},
], true),
'padding-before-expect-statements': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: 6,
},
{
paddingType: 0,
prevStatementType: 6,
nextStatementType: 6,
},
], true),
'padding-before-test-blocks': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: [10, 9],
},
], true),
'padding-before-all': padding_1.createRule([
{
paddingType: 1,
prevStatementType: 0,
nextStatementType: [
1,
2,
3,
4,
5,
6,
9,
10,
],
},
{
paddingType: 0,
prevStatementType: 6,
nextStatementType: 6,
},
], true),
'padding-around-all': padding_1.createRule([].concat(...Object.keys(paddingConfigs).map((k) => paddingConfigs[k]))),
};

@@ -201,0 +127,0 @@ exports.configs = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRule = exports.PaddingType = exports.StatementType = void 0;
const astUtils = require("../ast-utils");

@@ -108,3 +109,3 @@ var StatementType;

if (Array.isArray(statementType)) {
return statementType.some(type => nodeMatchesType(innerStatementNode, type, paddingContext));
return statementType.some((type) => nodeMatchesType(innerStatementNode, type, paddingContext));
}

@@ -111,0 +112,0 @@ return statementTesters[statementType](innerStatementNode, sourceCode);

{
"name": "eslint-plugin-jest-formatting",
"version": "1.2.0",
"version": "2.0.0",
"description": "Formatting rules for jest tests",

@@ -23,4 +23,4 @@ "keywords": [

"pretty": "yarn prettier '**/*.*'",
"lint": "yarn build && yarn link-plugin && yarn pretty --check && yarn eslint .",
"format": "yarn build && yarn link-plugin && yarn pretty --write && yarn eslint --fix .",
"lint": "yarn build && yarn link-plugin && yarn pretty --check && yarn eslint --ext .ts,.js .",
"format": "yarn build && yarn link-plugin && yarn pretty --write && yarn eslint --fix --ext .ts,.js .",
"build": "tsc",

@@ -34,23 +34,24 @@ "test": "yarn build && jest",

"devDependencies": {
"@types/eslint": "4.16.6",
"@types/estree": "0.0.39",
"@types/jest": "24.0.11",
"@types/node": "8.10.0",
"@typescript-eslint/parser": "1.10.2",
"eslint": "5.16.0",
"eslint-config-airbnb-base": "13.1.0",
"eslint-config-prettier": "5.0.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jest": "22.7.0",
"@types/eslint": "^7.2.0",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.13",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"eslint": "^7.3.1",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jest": "^23.17.1",
"eslint-plugin-jest-formatting": "file:.",
"eslint-plugin-prettier": "3.1.0",
"jest": "24.8.0",
"prettier": "1.18.2",
"typescript": "3.4.1",
"ts-jest": "24.0.2"
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.1.0",
"prettier": "2.0.5",
"typescript": "^3.9.5",
"ts-jest": "^26.1.1"
},
"engines": {
"node": ">=8.10.0"
"node": "^10.12.0 || >=12.0.0"
},
"license": "MIT"
}
[![CircleCI](https://circleci.com/gh/dangreenisrael/eslint-plugin-jest-formatting/tree/master.svg?style=svg)](https://circleci.com/gh/dangreenisrael/eslint-plugin-jest-formatting/tree/master)
![npm monthly downloads](https://img.shields.io/npm/dm/eslint-plugin-jest-formatting.svg)
**_Note: The master version may not be the version deployed to npm. Please treat https://www.npmjs.com/package/eslint-plugin-jest-formatting as the cannonical source for docs._**
# eslint-plugin-jest-formatting
This package provides ESLint rules for jest test suites.
This project aims to provide formatting rules (auto-fixable where possible) to ensure consistency and readability in jest test suites.

@@ -12,2 +12,4 @@

**_Note: The master version may not be the version deployed to npm. Please treat https://www.npmjs.com/package/eslint-plugin-jest-formatting as the cannonical source for docs._**
## Installation

@@ -79,11 +81,8 @@

### Deprecated
## Related Projects
- [padding-before-all](docs/rules/padding-before-all.md)
- [padding-before-before-each-blocks](docs/rules/padding-before-before-each-blocks.md)
- [padding-before-after-each-blocks](docs/rules/padding-before-after-each-blocks.md)
- [padding-before-before-all-blocks](docs/rules/padding-before-before-all-blocks.md)
- [padding-before-after-all-blocks](docs/rules/padding-before-after-all-blocks.md)
- [padding-before-describe-blocks](docs/rules/padding-before-describe-blocks.md)
- [padding-before-expect-statements](docs/rules/padding-before-expect-statements.md)
- [padding-before-test-blocks](docs/rules/padding-before-test-blocks.md)
### eslint-plugin-jest
This provides an extensive set of jest eslint rules
https://github.com/jest-community/eslint-plugin-jest
import { AST, SourceCode } from 'eslint';
// This is because we are using @types/estree that are brought in with eslint
// eslint-disable-next-line import/no-extraneous-dependencies
import { Node } from 'estree';

@@ -3,0 +5,0 @@

@@ -134,113 +134,4 @@ /**

'padding-around-all': createRule(
[].concat(...Object.keys(paddingConfigs).map(k => paddingConfigs[k])),
[].concat(...Object.keys(paddingConfigs).map((k) => paddingConfigs[k])),
),
// ===========================================================================
// DEPRECATED
'padding-before-after-all-blocks': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: StatementType.AfterAllToken,
},
],
true,
),
// DEPRECATED
'padding-before-after-each-blocks': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: StatementType.AfterEachToken,
},
],
true,
),
// DEPRECATED
'padding-before-before-all-blocks': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: StatementType.BeforeAllToken,
},
],
true,
),
// DEPRECATED
'padding-before-before-each-blocks': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: StatementType.BeforeEachToken,
},
],
true,
),
// DEPRECATED
'padding-before-describe-blocks': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: StatementType.DescribeToken,
},
],
true,
),
// DEPRECATED
'padding-before-expect-statements': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: StatementType.ExpectToken,
},
{
paddingType: PaddingType.Any,
prevStatementType: StatementType.ExpectToken,
nextStatementType: StatementType.ExpectToken,
},
],
true,
),
// DEPRECATED
'padding-before-test-blocks': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: [StatementType.TestToken, StatementType.ItToken],
},
],
true,
),
// DEPRECATED
'padding-before-all': createRule(
[
{
paddingType: PaddingType.Always,
prevStatementType: StatementType.Any,
nextStatementType: [
StatementType.AfterAllToken,
StatementType.AfterEachToken,
StatementType.BeforeAllToken,
StatementType.BeforeEachToken,
StatementType.DescribeToken,
StatementType.ExpectToken,
StatementType.ItToken,
StatementType.TestToken,
],
},
{
paddingType: PaddingType.Any,
prevStatementType: StatementType.ExpectToken,
nextStatementType: StatementType.ExpectToken,
},
],
true,
),
};

@@ -247,0 +138,0 @@

@@ -12,2 +12,4 @@ /**

import { AST, Rule, SourceCode } from 'eslint';
// This is because we are using @types/estree that are brought in with eslint
// eslint-disable-next-line import/no-extraneous-dependencies
import { Node } from 'estree';

@@ -223,3 +225,3 @@ import * as astUtils from '../ast-utils';

if (Array.isArray(statementType)) {
return statementType.some(type =>
return statementType.some((type) =>
nodeMatchesType(innerStatementNode, type, paddingContext),

@@ -276,4 +278,4 @@ );

// here as it's the only place that it's checked.
// @ts-ignore
if (!astUtils.isValidParent(node.parent.type)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (!astUtils.isValidParent((node as any).parent.type)) {
return;

@@ -320,3 +322,3 @@ }

configs: Config[],
deprecated: boolean = false,
deprecated = false,
): Rule.RuleModule => ({

@@ -323,0 +325,0 @@ meta: {

@@ -7,2 +7,4 @@ /**

/* eslint-disable @typescript-eslint/no-empty-function */
beforeAll(() => {});

@@ -9,0 +11,0 @@ beforeEach(() => {});

@@ -0,1 +1,3 @@

/* eslint-disable @typescript-eslint/no-empty-function */
beforeAll(() => {});

@@ -2,0 +4,0 @@

@@ -111,5 +111,6 @@ /**

},
]
],
output: valid,
},
]
});

@@ -109,5 +109,6 @@ /**

},
]
],
output: valid,
},
]
});

@@ -111,5 +111,6 @@ /**

},
]
],
output: valid,
},
]
});

@@ -111,5 +111,6 @@ /**

},
]
],
output: valid,
},
]
});

@@ -149,5 +149,6 @@ /**

},
]
],
output: valid,
},
]
});

@@ -151,5 +151,6 @@ /**

},
]
],
output: valid,
},
]
});

@@ -159,4 +159,5 @@ /**

],
output: valid,
},
],
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc