eslint-plugin-th-rules 2.7.0 → 2.8.0

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.
Files changed (74) hide show
  1. package/README.md +171 -11
  2. package/dist/configs/bundles/recommended-react.d.ts +199 -0
  3. package/dist/configs/bundles/recommended-react.js +11 -0
  4. package/dist/configs/bundles/recommended-typescript.d.ts +190 -0
  5. package/dist/configs/bundles/recommended-typescript.js +6 -0
  6. package/dist/configs/bundles/recommended.d.ts +190 -0
  7. package/dist/configs/bundles/recommended.js +8 -0
  8. package/dist/configs/core/base.d.ts +170 -0
  9. package/dist/configs/core/base.js +23 -0
  10. package/dist/configs/core/react.d.ts +6 -0
  11. package/dist/configs/core/react.js +8 -0
  12. package/dist/configs/core/typescript.d.ts +2 -0
  13. package/dist/configs/core/typescript.js +19 -0
  14. package/dist/configs/externals/base.d.ts +15 -0
  15. package/dist/configs/externals/base.js +16 -0
  16. package/dist/configs/externals/opinionated.d.ts +10 -0
  17. package/dist/configs/externals/opinionated.js +12 -0
  18. package/dist/index.d.ts +1170 -0
  19. package/dist/index.js +21 -0
  20. package/dist/plugin.d.ts +5 -0
  21. package/dist/plugin.js +14 -0
  22. package/dist/rules/no-boolean-coercion.d.ts +5 -0
  23. package/dist/rules/no-boolean-coercion.js +98 -0
  24. package/dist/rules/no-comments.d.ts +11 -0
  25. package/dist/rules/no-comments.js +83 -0
  26. package/dist/rules/no-default-export.d.ts +5 -0
  27. package/dist/rules/no-default-export.js +61 -0
  28. package/dist/rules/no-destructuring.d.ts +8 -0
  29. package/dist/rules/no-destructuring.js +121 -0
  30. package/dist/rules/prefer-is-empty.d.ts +5 -0
  31. package/dist/rules/prefer-is-empty.js +101 -0
  32. package/dist/rules/schemas-in-schemas-file.d.ts +9 -0
  33. package/dist/rules/schemas-in-schemas-file.js +141 -0
  34. package/dist/rules/top-level-functions.d.ts +5 -0
  35. package/dist/rules/top-level-functions.js +153 -0
  36. package/dist/rules/types-in-dts.d.ts +8 -0
  37. package/dist/rules/types-in-dts.js +76 -0
  38. package/package.json +25 -14
  39. package/.github/dependabot.yml +0 -15
  40. package/.github/workflows/codecov.yml +0 -26
  41. package/.github/workflows/codeql.yml +0 -82
  42. package/.github/workflows/dependency-review.yml +0 -20
  43. package/.github/workflows/main.yml +0 -43
  44. package/.github/workflows/scorecard.yml +0 -72
  45. package/.github/workflows/snyk-security.yml +0 -67
  46. package/.releaserc +0 -13
  47. package/.vscode/settings.json +0 -8
  48. package/.yarn/releases/yarn-4.12.0.cjs +0 -942
  49. package/.yarnrc.yml +0 -3
  50. package/CHANGELOG.md +0 -621
  51. package/SECURITY.md +0 -48
  52. package/docs/rules/no-boolean-coercion.md +0 -9
  53. package/docs/rules/no-comments.md +0 -50
  54. package/docs/rules/no-default-export.md +0 -26
  55. package/docs/rules/no-destructuring.md +0 -40
  56. package/docs/rules/prefer-is-empty.md +0 -9
  57. package/docs/rules/schemas-in-schemas-file.md +0 -170
  58. package/docs/rules/top-level-functions.md +0 -48
  59. package/docs/rules/types-in-dts.md +0 -112
  60. package/renovate.json +0 -3
  61. package/scripts/verify.mjs +0 -16
  62. package/src/index.js +0 -144
  63. package/src/rules/no-boolean-coercion.js +0 -125
  64. package/src/rules/no-comments.js +0 -94
  65. package/src/rules/no-default-export.js +0 -64
  66. package/src/rules/no-destructuring.js +0 -114
  67. package/src/rules/prefer-is-empty.js +0 -104
  68. package/src/rules/schemas-in-schemas-file.js +0 -191
  69. package/src/rules/top-level-functions.js +0 -200
  70. package/src/rules/types-in-dts.js +0 -94
  71. package/tests/no-boolean-coercion.test.ts +0 -83
  72. package/tests/prefer-is-empty.test.ts +0 -148
  73. package/tsconfig.json +0 -22
  74. package/xo.config.ts +0 -2
@@ -0,0 +1,141 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export default ESLintUtils.RuleCreator(() => 'https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/schemas-in-schemas-file.md')({
3
+ name: 'schemas-in-schemas-file',
4
+ meta: {
5
+ type: 'problem',
6
+ docs: {
7
+ description: 'Require Zod schema declarations to be placed in a .schemas.ts file.',
8
+ },
9
+ schema: [
10
+ {
11
+ type: 'object',
12
+ properties: {
13
+ allowedSuffixes: {
14
+ type: 'array',
15
+ items: { type: 'string', minLength: 1 },
16
+ minItems: 1,
17
+ },
18
+ onlyWhenAssigned: { type: 'boolean' },
19
+ allowInTests: { type: 'boolean' },
20
+ },
21
+ additionalProperties: false,
22
+ },
23
+ ],
24
+ messages: {
25
+ moveSchema: 'Zod schemas must be defined in a dedicated schemas file ({{suffixes}}).',
26
+ },
27
+ },
28
+ defaultOptions: [
29
+ {
30
+ allowedSuffixes: ['.schemas.ts'],
31
+ onlyWhenAssigned: false,
32
+ allowInTests: false,
33
+ },
34
+ ],
35
+ create(context, [options]) {
36
+ const allowedSuffixes = options.allowedSuffixes ?? ['.schemas.ts'];
37
+ const onlyWhenAssigned = Boolean(options.onlyWhenAssigned);
38
+ const allowInTests = Boolean(options.allowInTests);
39
+ const zodIdentifiers = new Set();
40
+ function filenameAllowed(filename) {
41
+ if (!filename || filename === '<input>') {
42
+ return false;
43
+ }
44
+ if (allowInTests
45
+ && /\.(test|spec)\.[jt]sx?$/.test(filename)) {
46
+ return true;
47
+ }
48
+ return allowedSuffixes.some(suffix => filename.endsWith(suffix));
49
+ }
50
+ function isZodModuleImport(node) {
51
+ return (node.source.type === 'Literal'
52
+ && node.source.value === 'zod');
53
+ }
54
+ function collectZodIdentifiersFromImport(node) {
55
+ if (!isZodModuleImport(node)) {
56
+ return;
57
+ }
58
+ for (const spec of node.specifiers) {
59
+ if (spec.type === 'ImportSpecifier'
60
+ && spec.imported.type === 'Identifier'
61
+ && spec.imported.name === 'z'
62
+ && spec.local.type === 'Identifier') {
63
+ zodIdentifiers.add(spec.local.name);
64
+ }
65
+ if (spec.type === 'ImportNamespaceSpecifier'
66
+ && spec.local.type === 'Identifier') {
67
+ zodIdentifiers.add(spec.local.name);
68
+ }
69
+ }
70
+ }
71
+ function isZodBuilderCall(node) {
72
+ const { callee } = node;
73
+ if (callee.type !== 'MemberExpression'
74
+ || callee.computed) {
75
+ return false;
76
+ }
77
+ const { object } = callee;
78
+ const { property } = callee;
79
+ return (object.type === 'Identifier'
80
+ && zodIdentifiers.has(object.name)
81
+ && property.type === 'Identifier');
82
+ }
83
+ function isZodChainedBuilderCall(node) {
84
+ const { callee } = node;
85
+ if (callee.type !== 'MemberExpression'
86
+ || callee.computed) {
87
+ return false;
88
+ }
89
+ let current = callee.object;
90
+ while (current.type === 'MemberExpression'
91
+ && !current.computed) {
92
+ current = current.object;
93
+ }
94
+ return (current.type === 'Identifier'
95
+ && zodIdentifiers.has(current.name));
96
+ }
97
+ function getAssignmentTargetName(callNode) {
98
+ const { parent } = callNode;
99
+ if (parent?.type === 'VariableDeclarator'
100
+ && parent.id.type === 'Identifier') {
101
+ return parent.id.name;
102
+ }
103
+ if (parent?.type === 'AssignmentExpression'
104
+ && parent.left.type === 'Identifier') {
105
+ return parent.left.name;
106
+ }
107
+ return null;
108
+ }
109
+ function report(node) {
110
+ const filename = context.getFilename();
111
+ if (filenameAllowed(filename)) {
112
+ return;
113
+ }
114
+ const targetName = getAssignmentTargetName(node);
115
+ if (onlyWhenAssigned && !targetName) {
116
+ return;
117
+ }
118
+ context.report({
119
+ node,
120
+ messageId: 'moveSchema',
121
+ data: {
122
+ suffixes: allowedSuffixes.join(' or '),
123
+ },
124
+ });
125
+ }
126
+ return {
127
+ ImportDeclaration(node) {
128
+ collectZodIdentifiersFromImport(node);
129
+ },
130
+ CallExpression(node) {
131
+ if (zodIdentifiers.size === 0) {
132
+ return;
133
+ }
134
+ if (isZodBuilderCall(node)
135
+ || isZodChainedBuilderCall(node)) {
136
+ report(node);
137
+ }
138
+ },
139
+ };
140
+ },
141
+ });
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ declare const _default: ESLintUtils.RuleModule<"arrow" | "funcExpr" | "anonDecl", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,153 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export default ESLintUtils.RuleCreator(() => 'https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/top-level-functions.md')({
3
+ name: 'top-level-functions',
4
+ meta: {
5
+ type: 'suggestion',
6
+ docs: {
7
+ description: 'Require all top-level functions to be named regular functions.',
8
+ },
9
+ fixable: 'code',
10
+ schema: [],
11
+ messages: {
12
+ arrow: 'Top-level arrow functions must be named regular functions.',
13
+ funcExpr: 'Top-level function expressions must be named regular functions.',
14
+ anonDecl: 'Top-level anonymous function declarations must be named.',
15
+ },
16
+ },
17
+ defaultOptions: [],
18
+ create(context) {
19
+ const sourceCode = context.getSourceCode();
20
+ //
21
+ // Helpers
22
+ //
23
+ function buildArrowFunctionReplacement(functionName, arrow, isExport) {
24
+ const asyncKeyword = arrow.async ? 'async ' : '';
25
+ const exportKeyword = isExport ? 'export ' : '';
26
+ const parametersText = arrow.params
27
+ .map(parameter => sourceCode.getText(parameter))
28
+ .join(', ');
29
+ let bodyText;
30
+ if (arrow.body.type === 'BlockStatement') {
31
+ bodyText = sourceCode.getText(arrow.body);
32
+ }
33
+ else {
34
+ // Expression → convert to return
35
+ const expressionText = sourceCode.getText(arrow.body);
36
+ bodyText = `{ return ${expressionText}; }`;
37
+ }
38
+ return `${exportKeyword}${asyncKeyword}function ${functionName}(${parametersText}) ${bodyText}`;
39
+ }
40
+ function buildFunctionExpressionReplacement(functionName, funcExpr, isExport) {
41
+ const asyncKeyword = funcExpr.async ? 'async ' : '';
42
+ const exportKeyword = isExport ? 'export ' : '';
43
+ const parametersText = funcExpr.params
44
+ .map(parameter => sourceCode.getText(parameter))
45
+ .join(', ');
46
+ const bodyText = sourceCode.getText(funcExpr.body);
47
+ return `${exportKeyword}${asyncKeyword}function ${functionName}(${parametersText}) ${bodyText}`;
48
+ }
49
+ function buildAnonymousFunctionDeclarationReplacement(node, functionName = 'defaultFunction', isExport = false) {
50
+ const originalText = sourceCode.getText(node);
51
+ const exportKeyword = isExport ? 'export ' : '';
52
+ const asyncFunctionRegex = /^\s*async\s+function\s*\(/;
53
+ const functionRegex = /^\s*function\s*\(/;
54
+ let replaced = originalText;
55
+ if (asyncFunctionRegex.test(replaced)) {
56
+ replaced = replaced.replace(asyncFunctionRegex, `async function ${functionName}(`);
57
+ }
58
+ else {
59
+ replaced = replaced.replace(functionRegex, `function ${functionName}(`);
60
+ }
61
+ if (isExport && !replaced.trimStart().startsWith('export')) {
62
+ replaced = `${exportKeyword}${replaced}`;
63
+ }
64
+ return replaced;
65
+ }
66
+ //
67
+ // Utility
68
+ //
69
+ function isTopLevel(node) {
70
+ const { parent } = node;
71
+ return (parent?.type === 'Program'
72
+ || parent?.type === 'ExportNamedDeclaration'
73
+ || parent?.type === 'ExportDefaultDeclaration');
74
+ }
75
+ function isExportContext(node) {
76
+ const p = node.parent;
77
+ return (p?.type === 'ExportNamedDeclaration'
78
+ || p?.type === 'ExportDefaultDeclaration');
79
+ }
80
+ //
81
+ // Rule
82
+ //
83
+ return {
84
+ VariableDeclarator(node) {
85
+ const declParent = node.parent;
86
+ const grandParent = declParent?.parent;
87
+ if (!grandParent) {
88
+ return;
89
+ }
90
+ const topLevel = grandParent.type === 'Program'
91
+ || grandParent.type === 'ExportNamedDeclaration'
92
+ || grandParent.type === 'ExportDefaultDeclaration';
93
+ if (!topLevel) {
94
+ return;
95
+ }
96
+ const isExport = grandParent.type === 'ExportNamedDeclaration'
97
+ || grandParent.type === 'ExportDefaultDeclaration';
98
+ if (!node.init) {
99
+ return;
100
+ }
101
+ const functionName = node.id.type === 'Identifier' ? node.id.name : null;
102
+ if (!functionName) {
103
+ return;
104
+ }
105
+ //
106
+ // Arrow functions
107
+ //
108
+ if (node.init.type === 'ArrowFunctionExpression') {
109
+ const arrowFunc = node.init;
110
+ context.report({
111
+ node: arrowFunc,
112
+ messageId: 'arrow',
113
+ fix(fixer) {
114
+ const replacement = buildArrowFunctionReplacement(functionName, arrowFunc, isExport);
115
+ return fixer.replaceText(isExport ? grandParent : declParent, replacement);
116
+ },
117
+ });
118
+ }
119
+ //
120
+ // Function expressions
121
+ //
122
+ if (node.init.type === 'FunctionExpression') {
123
+ const funcExpr = node.init;
124
+ context.report({
125
+ node: funcExpr,
126
+ messageId: 'funcExpr',
127
+ fix(fixer) {
128
+ const replacement = buildFunctionExpressionReplacement(functionName, funcExpr, isExport);
129
+ return fixer.replaceText(isExport ? grandParent : declParent, replacement);
130
+ },
131
+ });
132
+ }
133
+ },
134
+ FunctionDeclaration(node) {
135
+ if (node.id) {
136
+ return;
137
+ } // Already named
138
+ if (!isTopLevel(node)) {
139
+ return;
140
+ }
141
+ const isExport = isExportContext(node);
142
+ context.report({
143
+ node,
144
+ messageId: 'anonDecl',
145
+ fix(fixer) {
146
+ const replacement = buildAnonymousFunctionDeclarationReplacement(node, 'defaultFunction', isExport);
147
+ return fixer.replaceText(isExport ? node.parent : node, replacement);
148
+ },
149
+ });
150
+ },
151
+ };
152
+ },
153
+ });
@@ -0,0 +1,8 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ declare const _default: ESLintUtils.RuleModule<"moveToDts", [{
3
+ allowEnums: boolean;
4
+ allowDeclare: boolean;
5
+ }], unknown, ESLintUtils.RuleListener> & {
6
+ name: string;
7
+ };
8
+ export default _default;
@@ -0,0 +1,76 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export default ESLintUtils.RuleCreator(() => "https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/types-in-dts.md")({
3
+ name: "types-in-dts",
4
+ meta: {
5
+ type: "problem",
6
+ docs: {
7
+ description: "Require TypeScript type declarations (type/interface/enum) to be placed in .d.ts files."
8
+ },
9
+ schema: [
10
+ {
11
+ type: "object",
12
+ properties: {
13
+ allowEnums: { type: "boolean" },
14
+ allowDeclare: { type: "boolean" }
15
+ },
16
+ additionalProperties: false
17
+ }
18
+ ],
19
+ messages: {
20
+ moveToDts: "Type declarations must be defined in a .d.ts file."
21
+ }
22
+ },
23
+ defaultOptions: [
24
+ {
25
+ allowEnums: false,
26
+ allowDeclare: false
27
+ }
28
+ ],
29
+ create(context, [options]) {
30
+ const allowEnums = Boolean(options.allowEnums);
31
+ const allowDeclare = Boolean(options.allowDeclare);
32
+ function isDtsFile(filename) {
33
+ if (!filename || filename === "<input>") {
34
+ return false;
35
+ }
36
+ return filename.endsWith(".d.ts");
37
+ }
38
+ function hasDeclareModifier(node) {
39
+ // `declare type Foo = ...`
40
+ if ("declare" in node && node.declare === true) {
41
+ return true;
42
+ }
43
+ const modifiers = "modifiers" in node && Array.isArray(node.modifiers)
44
+ ? node.modifiers
45
+ : [];
46
+ return modifiers.some(m => m?.type === "TSDeclareKeyword");
47
+ }
48
+ function reportIfNotDts(node) {
49
+ const filename = context.getFilename();
50
+ if (isDtsFile(filename)) {
51
+ return;
52
+ }
53
+ if (allowDeclare && hasDeclareModifier(node)) {
54
+ return;
55
+ }
56
+ context.report({
57
+ node,
58
+ messageId: "moveToDts"
59
+ });
60
+ }
61
+ return {
62
+ TSTypeAliasDeclaration(node) {
63
+ reportIfNotDts(node);
64
+ },
65
+ TSInterfaceDeclaration(node) {
66
+ reportIfNotDts(node);
67
+ },
68
+ TSEnumDeclaration(node) {
69
+ if (allowEnums) {
70
+ return;
71
+ }
72
+ reportIfNotDts(node);
73
+ }
74
+ };
75
+ }
76
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-th-rules",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "A List of custom ESLint rules created by Tomer Horowitz",
5
5
  "keywords": [
6
6
  "eslint",
@@ -8,24 +8,29 @@
8
8
  "eslint-plugin"
9
9
  ],
10
10
  "author": "Tomer Horowitz",
11
- "main": "./src/index.js",
12
- "exports": "./src/index.js",
11
+ "type": "module",
12
+ "exports": "./dist/index.js",
13
+ "main": "./dist/index.js",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
13
20
  "scripts": {
14
- "lint": "npm-run-all \"lint:*\"",
15
- "lint:eslint-docs": "npm-run-all \"update:eslint-docs -- --check\"",
16
- "lint:js": "eslint .",
21
+ "build": "tsc",
17
22
  "update:eslint-docs": "eslint-doc-generator --config-emoji \"recommended,✅\" --config-emoji \"recommended-react,⚛️\" --config-emoji \"recommended-typescript,🟦\""
18
23
  },
19
24
  "dependencies": {
20
- "@babel/eslint-parser": "^7.28.5",
25
+ "@babel/eslint-parser": "^7.28.6",
21
26
  "@eslint/eslintrc": "^3.3.3",
22
27
  "eslint-config-jsdoc": "^15.4.0",
23
28
  "eslint-config-xo": "^0.49.0",
24
29
  "eslint-config-xo-react": "^0.29.0",
25
30
  "eslint-plugin-import": "^2.32.0",
26
- "eslint-plugin-jsdoc": "^61.5.0",
31
+ "eslint-plugin-jsdoc": "^62.0.0",
27
32
  "eslint-plugin-lodash": "^8.0.0",
28
- "eslint-plugin-n": "^17.23.1",
33
+ "eslint-plugin-n": "^17.23.2",
29
34
  "eslint-plugin-react": "^7.37.5",
30
35
  "eslint-plugin-react-hooks": "^7.0.1",
31
36
  "eslint-plugin-react-native": "^5.0.0",
@@ -33,7 +38,6 @@
33
38
  "eslint-plugin-sonarjs": "^3.0.5",
34
39
  "eslint-plugin-unicorn": "^62.0.0",
35
40
  "globals": "^17.0.0",
36
- "jest": "^30.2.0",
37
41
  "lodash": "^4.17.21",
38
42
  "requireindex": "^1.2.0"
39
43
  },
@@ -48,20 +52,27 @@
48
52
  "@semantic-release/release-notes-generator": "^14.1.0",
49
53
  "@types/eslint-plugin-security": "^3.0.0",
50
54
  "@types/eslint__js": "^9.14.0",
51
- "@types/lodash": "^4",
55
+ "@types/jest": "^30.0.0",
56
+ "@types/lodash": "^4.17.23",
57
+ "@types/node": "^25.0.9",
52
58
  "@types/requireindex": "^1.2.4",
53
59
  "@types/xo": "^0.39.9",
60
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
61
+ "@typescript-eslint/parser": "^8.53.0",
54
62
  "@typescript-eslint/rule-tester": "^8.53.0",
55
63
  "bun-types": "latest",
56
64
  "eslint": "^9.39.2",
57
65
  "eslint-doc-generator": "^3.0.2",
58
- "eslint-plugin-eslint-plugin": "^7.2.0",
66
+ "eslint-plugin-eslint-plugin": "^7.3.0",
59
67
  "eslint-plugin-node": "^11.1.0",
60
- "eslint-plugin-th-rules": "2.0.4",
68
+ "eslint-plugin-th-rules": "2.7.1",
69
+ "jest": "^30.2.0",
61
70
  "mocha": "^11.7.5",
62
71
  "npm-run-all": "^4.1.5",
72
+ "semantic-release": "^25.0.2",
73
+ "ts-jest": "^29.4.6",
63
74
  "typescript": "^5.9.3",
64
- "typescript-eslint": "^8.52.0",
75
+ "typescript-eslint": "^8.53.0",
65
76
  "xo": "^1.2.3"
66
77
  },
67
78
  "license": "ISC",
@@ -1,15 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: "npm" # See documentation for possible values
9
- directory: "/" # Location of package manifests
10
- schedule:
11
- interval: "weekly"
12
- - package-ecosystem: "docker" # See documentation for possible values
13
- directory: "/" # Location of package manifests
14
- schedule:
15
- interval: "weekly"
@@ -1,26 +0,0 @@
1
- name: Codecov
2
- on:
3
- push:
4
- branches:
5
- - main # or master, or whichever branch you want this to run on
6
- merge_group:
7
- branches:
8
- - main
9
- pull_request:
10
-
11
- jobs:
12
- release:
13
- runs-on: ubuntu-latest
14
- permissions:
15
- contents: write # to be able to publish a GitHub release
16
- issues: write # to be able to comment on released issues
17
- pull-requests: write # to be able to comment on released pull requests
18
- id-token: write # to enable use of OIDC for npm provenance
19
-
20
- steps:
21
- - name: Checkout
22
- uses: actions/checkout@v4
23
- - name: Upload coverage reports to Codecov
24
- uses: codecov/codecov-action@v4
25
- env:
26
- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -1,82 +0,0 @@
1
- # For most projects, this workflow file will not need changing; you simply need
2
- # to commit it to your repository.
3
- #
4
- # You may wish to alter this file to override the set of languages analyzed,
5
- # or to provide custom queries or build logic.
6
- #
7
- # ******** NOTE ********
8
- # We have attempted to detect the languages in your repository. Please check
9
- # the `language` matrix defined below to confirm you have the correct set of
10
- # supported CodeQL languages.
11
- #
12
- name: "CodeQL"
13
-
14
- on:
15
- push:
16
- branches: [ "main" ]
17
- pull_request:
18
- # The branches below must be a subset of the branches above
19
- branches: [ "main" ]
20
- schedule:
21
- - cron: '43 18 * * 5'
22
-
23
- jobs:
24
- analyze:
25
- name: Analyze
26
- # Runner size impacts CodeQL analysis time. To learn more, please see:
27
- # - https://gh.io/recommended-hardware-resources-for-running-codeql
28
- # - https://gh.io/supported-runners-and-hardware-resources
29
- # - https://gh.io/using-larger-runners
30
- # Consider using larger runners for possible analysis time improvements.
31
- runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
32
- timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
33
- permissions:
34
- actions: read
35
- contents: read
36
- security-events: write
37
-
38
- strategy:
39
- fail-fast: false
40
- matrix:
41
- language: [ 'javascript' ]
42
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
43
- # Use only 'java' to analyze code written in Java, Kotlin or both
44
- # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
45
- # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
46
-
47
- steps:
48
- - name: Checkout repository
49
- uses: actions/checkout@v4
50
-
51
- # Initializes the CodeQL tools for scanning.
52
- - name: Initialize CodeQL
53
- uses: github/codeql-action/init@v3
54
- with:
55
- languages: ${{ matrix.language }}
56
- # If you wish to specify custom queries, you can do so here or in a config file.
57
- # By default, queries listed here will override any specified in a config file.
58
- # Prefix the list here with "+" to use these queries and those in the config file.
59
-
60
- # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
61
- # queries: security-extended,security-and-quality
62
-
63
-
64
- # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
65
- # If this step fails, then you should remove it and run the build manually (see below)
66
- - name: Autobuild
67
- uses: github/codeql-action/autobuild@v3
68
-
69
- # ℹ️ Command-line programs to run using the OS shell.
70
- # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
71
-
72
- # If the Autobuild fails above, remove it and uncomment the following three lines.
73
- # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
74
-
75
- # - run: |
76
- # echo "Run, Build Application using script"
77
- # ./location_of_script_within_repo/buildscript.sh
78
-
79
- - name: Perform CodeQL Analysis
80
- uses: github/codeql-action/analyze@v3
81
- with:
82
- category: "/language:${{matrix.language}}"
@@ -1,20 +0,0 @@
1
- # Dependency Review Action
2
- #
3
- # This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
4
- #
5
- # Source repository: https://github.com/actions/dependency-review-action
6
- # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
7
- name: 'Dependency Review'
8
- on: [pull_request]
9
-
10
- permissions:
11
- contents: read
12
-
13
- jobs:
14
- dependency-review:
15
- runs-on: ubuntu-latest
16
- steps:
17
- - name: 'Checkout Repository'
18
- uses: actions/checkout@v4
19
- - name: 'Dependency Review'
20
- uses: actions/dependency-review-action@v4
@@ -1,43 +0,0 @@
1
- name: Semantic Versioning
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: write
13
- issues: write
14
- pull-requests: write
15
- id-token: write
16
-
17
- steps:
18
- - name: Checkout
19
- uses: actions/checkout@v4
20
-
21
- - name: Setup Bun
22
- uses: oven-sh/setup-bun@v1
23
-
24
- - name: Setup Node.js environment
25
- uses: actions/setup-node@v4
26
- with:
27
- node-version: "22.x"
28
-
29
- - name: Install Dependencies
30
- run: bun install --dev
31
-
32
- - name: Verify ESLint flat configs
33
- run: node ./scripts/verify.mjs
34
-
35
- - name: Run Tests
36
- run: bun test
37
-
38
- - name: Semantic Release
39
- run: bunx semantic-release
40
- env:
41
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
42
- GH_TOKEN: ${{ secrets.GH_TOKEN }}
43
- GH_REPO: ${{ github.server_url }}/${{ github.repository }}