@express-zod-api/migration 26.0.0-beta.2 → 27.0.0-beta.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Anna Bocharova
3
+ Copyright (c) 2026 Anna Bocharova
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -13,11 +13,11 @@ The minimal configuration to apply migrations automatically using `eslint --fix`
13
13
 
14
14
  ```js
15
15
  // eslint.config.mjs
16
- import parser from "@typescript-eslint/parser";
16
+ import { parser } from "typescript-eslint";
17
17
  import migration from "@express-zod-api/migration";
18
18
 
19
19
  export default [
20
20
  { languageOptions: { parser }, plugins: { migration } },
21
- { files: ["**/*.ts"], rules: { "migration/v26": "error" } },
21
+ { files: ["**/*.ts"], rules: { "migration/v27": "error" } },
22
22
  ];
23
23
  ```
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- import{AST_NODE_TYPES as e,ESLintUtils as t}from"@typescript-eslint/utils";const n={dependsOnMethod:`${e.NewExpression}[callee.name='DependsOnMethod']`,handlerOptions:`${e.ObjectExpression} > ${e.Property}[key.name='handler'] > ${e.ArrowFunctionExpression} > ${e.ObjectPattern} > ${e.Property}[key.name='options']`,addOptions:`${e.CallExpression}:has( ${e.ArrowFunctionExpression} ) > ${e.MemberExpression} > ${e.Identifier}[name='addOptions']`,testMiddlewareOptions:`${e.CallExpression}[callee.name='testMiddleware'] > ${e.ObjectExpression} > ${e.Property}[key.name='options']`},r=t=>t.type===e.Property&&!t.computed&&(t.key.type===e.Identifier||t.key.type===e.Literal&&typeof t.key.value==`string`),i=t=>t.key.type===e.Identifier?t.key.name:t.key.value,a=e=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[n[r]]:e[r]}),{}),o=`v${`26.0.0-beta.2`?.split(`.`)[0]??`0`}`,s=t.RuleCreator.withoutDocs({meta:{type:`problem`,fixable:`code`,schema:[],messages:{change:`change {{ subject }} from {{ from }} to {{ to }}`,add:`add {{ subject }} to {{ to }}`,move:`move {{ subject }} to {{ to }}`,remove:`remove {{ subject }}`}},defaultOptions:[],create:t=>a({dependsOnMethod:n=>{if(n.arguments.length!==1)return;let a=n.arguments[0];if(a.type!==e.ObjectExpression)return;let o=!1,s,c=n;for(;c&&c.parent&&c.parent.type===e.MemberExpression&&c.parent.property.type===e.Identifier&&c.parent.parent&&c.parent.parent.type===e.CallExpression;){let t=c.parent.property.name,n=c.parent.parent;t===`deprecated`&&(o=!0),t===`nest`&&n.arguments[0]&&n.arguments[0].type===e.ObjectExpression&&(s=n.arguments[0]),c=n}t.report({node:c,messageId:`change`,data:{subject:`value`,from:`new DependsOnMethod(...)`,to:`its argument`},fix:e=>{let n=e=>n=>r(n)?`${e===`nest`?t.sourceCode.getText(n.key):i(n)}: ${t.sourceCode.getText(n.value)}${e===`deprecated`?`.deprecated()`:``},`:`${t.sourceCode.getText(n)}, /** @todo migrate manually */`,l=a.properties.map(n(o?`deprecated`:void 0)).concat(s?.properties.map(n(`nest`))??[]).join(`
2
- `);return e.replaceText(c,`{\n${l}\n}`)}})},handlerOptions:e=>{t.report({node:e,messageId:`change`,data:{subject:`property`,from:`options`,to:`ctx`},fix:t=>t.replaceText(e.key,`ctx`)})},addOptions:e=>{t.report({node:e,messageId:`change`,data:{subject:`method`,from:`addOptions`,to:`addContext`},fix:t=>t.replaceText(e,`addContext`)})},testMiddlewareOptions:e=>{t.report({node:e,messageId:`change`,data:{subject:`property`,from:`options`,to:`ctx`},fix:t=>t.replaceText(e.key,`ctx`)})}})});var c={rules:{[o]:s}};export{c as default};
1
+ import{AST_NODE_TYPES as e,ESLintUtils as t}from"@typescript-eslint/utils";const n={integration:`${e.NewExpression}[callee.name="Integration"] > ${e.ObjectExpression}`},r=t=>t.type===e.Property&&!t.computed&&(t.key.type===e.Identifier||t.key.type===e.Literal&&typeof t.key.value==`string`),i=t=>t.key.type===e.Identifier?t.key.name:t.key.value,a=e=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[n[r]]:e[r]}),{}),o=`v${`27.0.0-beta.1`?.split(`.`)[0]??`0`}`,s=t.RuleCreator.withoutDocs({name:o,meta:{type:`problem`,fixable:`code`,schema:[],messages:{change:`change {{ subject }} from {{ from }} to {{ to }}`,add:`add {{ subject }} to {{ to }}`,move:`move {{ subject }} to {{ to }}`,remove:`remove {{ subject }}`}},defaultOptions:[],create:t=>a({integration:n=>{if(n.properties.filter(r).find(e=>i(e)===`typescript`))return;let a=t.sourceCode.getAncestors(n).some(t=>t.type===e.AwaitExpression||(t.type===e.ArrowFunctionExpression||t.type===e.FunctionExpression||t.type===e.FunctionDeclaration)&&t.async);t.report(a?{node:n.parent,messageId:`change`,data:{subject:`constructor`,from:`new Integration()`,to:`await Integration.create()`},fix:e=>e.replaceText(n.parent,`(await Integration.create(${t.sourceCode.getText(n)}))`)}:{node:n,messageId:`add`,data:{subject:`typescript property`,to:`constructor argument`},fix:e=>[e.insertTextBeforeRange(t.sourceCode.ast.range,`import typescript from "typescript";
2
+
3
+ `),n.properties.length?e.insertTextBefore(n.properties[0],`typescript, `):e.replaceText(n,`{ typescript }`)]})}})});var c={rules:{[o]:s}};export{c as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@express-zod-api/migration",
3
- "version": "26.0.0-beta.2",
3
+ "version": "27.0.0-beta.1",
4
4
  "license": "MIT",
5
5
  "description": "Migration scripts for express-zod-api",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "typescript-eslint": "^8.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@typescript-eslint/rule-tester": "^8.46.1"
39
+ "@typescript-eslint/rule-tester": "^8.51.0"
40
40
  },
41
41
  "scripts": {
42
42
  "pretest": "tsc",