Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2e7f15

Browse files
committed
add a new package and fork the base class
1 parent f84bf4a commit d2e7f15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5836
-84
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ packages/types/src/generated/**/*.ts
1212

1313
# Playground types downloaded from the web
1414
packages/website/src/vendor
15+
16+
# see the file header in eslint-base.test.js for more info
17+
packages/rule-tester/tests/eslint-base

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ CHANGELOG.md
1818

1919
packages/website/.docusaurus
2020
packages/website/build
21+
22+
# see the file header in eslint-base.test.js for more info
23+
packages/rule-tester/tests/eslint-base

packages/eslint-plugin-tslint/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"typecheck": "tsc -p tsconfig.json --noEmit"
4747
},
4848
"dependencies": {
49-
"@typescript-eslint/utils": "5.56.0",
50-
"lodash": "^4.17.21"
49+
"@typescript-eslint/utils": "5.56.0"
5150
},
5251
"peerDependencies": {
5352
"eslint": "^7.0.0 || ^8.0.0",

packages/eslint-plugin-tslint/src/rules/config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import { ESLintUtils } from '@typescript-eslint/utils';
2-
import memoize from 'lodash/memoize';
32
import type { RuleSeverity } from 'tslint';
43
import { Configuration } from 'tslint';
54

65
import { CustomLinter } from '../custom-linter';
76

7+
function memoize<T extends (...args: never[]) => unknown>(
8+
func: T,
9+
resolver: (...args: Parameters<T>) => string,
10+
): T {
11+
const cache = new Map<string, ReturnType<T>>();
12+
const memoized = function (...args) {
13+
const key = resolver(...(args as Parameters<T>));
14+
15+
if (cache.has(key)) {
16+
return cache.get(key)!;
17+
}
18+
const result = func(...args);
19+
cache.set(key, result as ReturnType<T>);
20+
return result;
21+
} as T;
22+
return memoized;
23+
}
24+
825
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
926
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1027
const version: string = require('../../package.json');

packages/rule-tester/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 typescript-eslint and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/rule-tester/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# `@typescript-eslint/rule-tester`
2+
3+
> Tooling to test ESLint rules
4+
5+
[![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/rule-tester.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/rule-tester)
6+
[![NPM Downloads](https://img.shields.io/npm/dm/@typescript-eslint/rule-tester.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/rule-tester)
7+
8+
👉 See **https://typescript-eslint.io/architecture/rule-tester** for documentation on this package.

packages/rule-tester/jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
// @ts-check
4+
/** @type {import('@jest/types').Config.InitialOptions} */
5+
module.exports = {
6+
...require('../../jest.config.base.js'),
7+
};

packages/rule-tester/package.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"name": "@typescript-eslint/rule-tester",
3+
"version": "5.56.0",
4+
"description": "Tooling to test ESLint rules",
5+
"files": [
6+
"dist",
7+
"_ts4.2",
8+
"README.md",
9+
"LICENSE"
10+
],
11+
"type": "commonjs",
12+
"exports": {
13+
".": {
14+
"types": "./dist/index.d.ts",
15+
"default": "./dist/index.js"
16+
},
17+
"./package.json": "./package.json"
18+
},
19+
"engines": {
20+
"node": "^14.18.0 || ^16.0.0 || >=18.0.0"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/typescript-eslint/typescript-eslint.git",
25+
"directory": "packages/rule-tester"
26+
},
27+
"bugs": {
28+
"url": "https://github.com/typescript-eslint/typescript-eslint/issues"
29+
},
30+
"license": "MIT",
31+
"keywords": [
32+
"eslint",
33+
"typescript",
34+
"estree"
35+
],
36+
"scripts": {
37+
"build": "tsc -b tsconfig.build.json",
38+
"postbuild": "downlevel-dts dist _ts4.2/dist --to=4.2",
39+
"clean": "tsc -b tsconfig.build.json --clean",
40+
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage",
41+
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
42+
"lint": "nx lint",
43+
"pretest-eslint-base": "tsc -b tsconfig.build.json",
44+
"test-eslint-base": "mocha --require source-map-support/register ./tests/eslint-base/eslint-base.test.js",
45+
"test": "jest --coverage",
46+
"typecheck": "tsc -p tsconfig.json --noEmit"
47+
},
48+
"//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70",
49+
"dependencies": {
50+
"@typescript-eslint/typescript-estree": "5.56.0",
51+
"@typescript-eslint/utils": "5.56.0",
52+
"lodash.merge": "4.6.2",
53+
"semver": "^7.3.7",
54+
"ajv": "^6.10.0"
55+
},
56+
"peerDependencies": {
57+
"@eslint/eslintrc": ">=2",
58+
"eslint": ">=8"
59+
},
60+
"devDependencies": {
61+
"@types/lodash.merge": "4.6.7",
62+
"chai": "^4.0.1",
63+
"mocha": "^8.3.2",
64+
"sinon": "^11.0.0",
65+
"source-map-support": "^0.5.21"
66+
},
67+
"funding": {
68+
"type": "opencollective",
69+
"url": "https://opencollective.com/typescript-eslint"
70+
},
71+
"typesVersions": {
72+
"<3.8": {
73+
"*": [
74+
"_ts3.4/*"
75+
]
76+
}
77+
}
78+
}

packages/rule-tester/project.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "rule-tester",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"type": "library",
5+
"implicitDependencies": [],
6+
"targets": {
7+
"lint": {
8+
"executor": "@nrwl/linter:eslint",
9+
"outputs": ["{options.outputFile}"],
10+
"options": {
11+
"lintFilePatterns": ["packages/rule-tester/**/*.ts"]
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)