@containerbase/eslint-plugin 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Containerbase
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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # eslint-plugin
2
+
3
+ containerbase eslint plugin
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import eslint from 'eslint';
2
+
3
+ const plugin: eslint.ESLint.Plugin & {
4
+ configs: {
5
+ all: eslint.Linter.Config;
6
+ };
7
+ };
8
+
9
+ export default plugin;
package/index.js ADDED
@@ -0,0 +1,82 @@
1
+ import process from 'node:process';
2
+ import pkg from './package.json' with { type: 'json' };
3
+
4
+ /** @type {Record<string, import('eslint').Rule.RuleModule>} */
5
+ const rules = {
6
+ 'test-root-describe': {
7
+ meta: {
8
+ fixable: 'code',
9
+ },
10
+ create(context) {
11
+ const absoluteFileName = context.filename;
12
+ if (!absoluteFileName.endsWith('.spec.ts')) {
13
+ return {};
14
+ }
15
+ const relativeFileName = absoluteFileName
16
+ .replace(process.cwd(), '')
17
+ .replace(/\\/g, '/')
18
+ .replace(/^(?:\/(?:lib|src|test))?\//, '');
19
+ const testName = relativeFileName.replace(/\.spec\.ts$/, '');
20
+ return {
21
+ CallExpression(node) {
22
+ const { callee } = node;
23
+ if (
24
+ callee.type === 'Identifier' &&
25
+ callee.name === 'describe' &&
26
+ node.parent.parent.type === 'Program'
27
+ ) {
28
+ const [descr] = node.arguments;
29
+
30
+ if (!descr) {
31
+ context.report({
32
+ node,
33
+ message: `Test root describe must have arguments`,
34
+ });
35
+ return;
36
+ }
37
+
38
+ const isOkay =
39
+ descr.type === 'Literal' &&
40
+ typeof descr.value === 'string' &&
41
+ testName === descr.value;
42
+ if (!isOkay) {
43
+ context.report({
44
+ node: descr,
45
+ message: `Test must be described by this string: '${testName}'`,
46
+ fix(fixer) {
47
+ return fixer.replaceText(descr, `'${testName}'`);
48
+ },
49
+ });
50
+ }
51
+ }
52
+ },
53
+ };
54
+ },
55
+ },
56
+ };
57
+
58
+ /** @type {Record<string, import('eslint').Linter.Config> } */
59
+ const configs = {
60
+ all: {
61
+ plugins: {
62
+ get '@containerbase'() {
63
+ return plugin;
64
+ },
65
+ },
66
+ rules: {
67
+ '@containerbase/test-root-describe': 'error',
68
+ },
69
+ },
70
+ };
71
+
72
+ /** @type {import('eslint').ESLint.Plugin} */
73
+ const plugin = {
74
+ meta: {
75
+ name: pkg.name,
76
+ version: pkg.version,
77
+ },
78
+ rules,
79
+ configs,
80
+ };
81
+
82
+ export default plugin;
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@containerbase/eslint-plugin",
3
+ "version": "1.0.1",
4
+ "description": "containerbase eslint plugin",
5
+ "keywords": [
6
+ "eslint-plugin",
7
+ "jest",
8
+ "vitest"
9
+ ],
10
+ "repository": "https://github.com/containerbase/eslint-plugin.git",
11
+ "license": "MIT",
12
+ "author": "Rhys Arkins <rhys@arkins.net>",
13
+ "contributors": [
14
+ "Michael Kriese <michael.kriese@visualon.de>"
15
+ ],
16
+ "type": "module",
17
+ "main": "index.js",
18
+ "files": [
19
+ "index.js",
20
+ "index.d.ts"
21
+ ],
22
+ "scripts": {
23
+ "eslint": "eslint --cache .",
24
+ "eslint-fix": "eslint --cache --fix .",
25
+ "lint": "run-s prettier eslint lint:types",
26
+ "lint:types": "run-p 'lint:types:*'",
27
+ "lint:types:default": "tsc",
28
+ "lint-fix": "run-s prettier-fix eslint-fix",
29
+ "prepare": "husky",
30
+ "prettier": "prettier --cache -c -u \"**/*.*\"",
31
+ "prettier-fix": "prettier --cache -w -u \"**/*.*\""
32
+ },
33
+ "devDependencies": {
34
+ "@eslint/js": "9.14.0",
35
+ "@tsconfig/node20": "20.1.4",
36
+ "@tsconfig/strictest": "2.0.5",
37
+ "@types/eslint-config-prettier": "^6.11.3",
38
+ "@types/node": "^22.9.0",
39
+ "conventional-changelog-conventionalcommits": "8.0.0",
40
+ "eslint": "^9.14.0",
41
+ "eslint-config-prettier": "9.1.0",
42
+ "eslint-formatter-gha": "1.5.1",
43
+ "eslint-import-resolver-typescript": "3.6.3",
44
+ "eslint-plugin-import": "2.31.0",
45
+ "husky": "9.1.6",
46
+ "lint-staged": "15.2.10",
47
+ "npm-run-all2": "7.0.1",
48
+ "prettier": "3.3.3",
49
+ "prettier-plugin-packagejson": "2.5.3",
50
+ "semantic-release": "24.2.0",
51
+ "typescript": "^5.6.3",
52
+ "typescript-eslint": "^8.13.0"
53
+ },
54
+ "peerDependencies": {
55
+ "eslint": "^9.0.0"
56
+ },
57
+ "packageManager": "pnpm@9.12.3",
58
+ "engines": {
59
+ "node": "^20.9.0 || ^22.11.0",
60
+ "pnpm": "^9.0.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }