Title: Create an ESLint rule for migrating to scoped packages imports · Issue #8131 · NativeScript/NativeScript · GitHub
Open Graph Title: Create an ESLint rule for migrating to scoped packages imports · Issue #8131 · NativeScript/NativeScript
X Title: Create an ESLint rule for migrating to scoped packages imports · Issue #8131 · NativeScript/NativeScript
Description: Why? Provide an automated way to migrate imports and require statements from: tns-core-modules to @nativescript/core; and nativescript-angular to @nativescript/angular. How? The above can be achieved by providing an ESLint rule that dete...
Open Graph Description: Why? Provide an automated way to migrate imports and require statements from: tns-core-modules to @nativescript/core; and nativescript-angular to @nativescript/angular. How? The above can be achiev...
X Description: Why? Provide an automated way to migrate imports and require statements from: tns-core-modules to @nativescript/core; and nativescript-angular to @nativescript/angular. How? The above can be achiev...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/8131
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Create an ESLint rule for migrating to scoped packages imports ","articleBody":"# Why?\r\n\r\nProvide an automated way to migrate `imports` and `require` statements from:\r\n- `tns-core-modules` to `@nativescript/core`;\r\n- and `nativescript-angular` to `@nativescript/angular`.\r\n\r\n# How?\r\n\r\nThe above can be achieved by providing an ESLint rule that detects the old type of imports and recommends using the new one. It should also provide an autofix that migrates the imports.\r\n\r\n# Migration description\r\n\r\n## JS/TS\r\n\r\nThe rule should work for both JS and TS projects.\r\n\r\n## `tns-core-modules` -\u003e `@nativescript/core`\r\n\r\nThe rule should migrate the imports from that package in the following way:\r\n\r\n### for imports from `application`, `application-settings`, `connectivity`, `image-asset`, `trace`:\r\n\r\n1. `import { run } from \"tns-core-modules/application\"` -\u003e\r\n`import { Application } from \"@nativescript/core\"`\r\n2. `const run = require(\"tns-core-modules/application\").run` -\u003e\r\n`const Application = require(\"@nativescript/core/application\")`\r\n\r\nIn cases 1 and 2, the rule should also change all uses of `run` in the code to `Application.run`.\r\n\r\n3. `import * as application from \"tns-core-modules/application\"` -\u003e\r\n`import { Application } from \"@nativescript/core\"`\r\n4. `const application = require(\"tns-core-modules/application\")` -\u003e\r\n`const Application = require(\"@nativescript/core\").Application`\r\n\r\nIn cases 3 and 4, the rule should also change all uses of `application` in the code to `Application`.\r\n\r\n### for imports from `utils/utils`:\r\n\r\nThe same as `application` with this exception:\r\n\r\nimport * as utils from \"tns-core-modules/utils/utils\";\r\nutils.ad;\r\n`\r\n-\u003e\r\n`\r\nimport { Utils } from \"@nativescript/core\";\r\nUtils.android;\r\n`\r\n\r\n### for imports from `profiling`:\r\n\r\nMigrate to `import { Profiling } from @nativescript/core` for the methods that are now exported through the `Profiling` constant from `@nativescript/core`:\r\nhttps://github.com/NativeScript/NativeScript/blob/8d2dd2eb21965f988f339a1c17683712cdfc3654/nativescript-core/index.ts#L69-L76\r\n\r\nMigrate to `import { SomeInterface } from '@nativescript/core'` for all symbols that are now directly exported from `@nativescript/core`:\r\nhttps://github.com/NativeScript/NativeScript/blob/8d2dd2eb21965f988f339a1c17683712cdfc3654/nativescript-core/index.ts#L60\r\n\r\n### for imports from `trace`:\r\n\r\nMigrate to `import { Trace } from @nativescript/core` for the methods that are now exported through the `Trace` constant from `@nativescript/core`:\r\nhttps://github.com/NativeScript/NativeScript/blob/8d2dd2eb21965f988f339a1c17683712cdfc3654/nativescript-core/index.ts#L88-L93\r\n\r\nMigrate to `import { SomeInterface } from '@nativescript/core'` for all symbols that are now directly exported from `@nativescript/core`:\r\nhttps://github.com/NativeScript/NativeScript/blob/8d2dd2eb21965f988f339a1c17683712cdfc3654/nativescript-core/index.ts#L80\r\n\r\n### for imports from `http`:\r\n\r\nMigrate to `import { Http } from @nativescript/core` for the methods that are now exported through the `Http` constant from `@nativescript/core`:\r\nhttps://github.com/NativeScript/NativeScript/blob/8d2dd2eb21965f988f339a1c17683712cdfc3654/nativescript-core/index.ts#L52\r\nMigrate to `import { SomeInterface } from '@nativescript/core'` for all symbols that are now directly exported from `@nativescript/core`:\r\nhttps://github.com/NativeScript/NativeScript/blob/8d2dd2eb21965f988f339a1c17683712cdfc3654/nativescript-core/index.ts#L49\r\n\r\n### for imports from `platform`:\r\n\r\nFor `isAndroid` and `isIOS` migrate to `@nativescript/core`.\r\nFor `screen` and `device` migrate to `import { Screen, Device } from '@nativescript/core';`.\r\nFor any other path migrate to `@nativescript/core/platform`.\r\n\r\n### for imports from `ui/*`, `data/observable-array`, `data/observable`, `file-system`, `color`, `image-asset`, `image-source`, `text`, `xml`:\r\n\r\n1. `import { Observable } from \"tns-core-modules/data/observable\"` -\u003e\r\n`import { Observable } from \"@nativescript/core\"`\r\n2. `const Observable = require(\"tns-core-modules/data/observable\")` -\u003e\r\n`const Observable = require(\"@nativescript/core\").Observable`\r\n\r\n### for every other import starting with `tns-core-modules`, the `tns-core-modules` prefix should be replaced with `@nativescript/core`.\r\n\r\n## `nativescript/angular` -\u003e `@nativescript/angular`","author":{"url":"https://github.com/sis0k0","@type":"Person","name":"sis0k0"},"datePublished":"2019-11-21T14:43:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/8131/NativeScript/issues/8131"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9327a7b3-5b39-b0d5-b2ac-db32d678a1f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C306:371948:1954B6C:2255A17:697A9EB5 |
| html-safe-nonce | c27553b470fb8799ef91ff69c5c62e466a64fb03e07386b0820c770bf884cbc6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzA2OjM3MTk0ODoxOTU0QjZDOjIyNTVBMTc6Njk3QTlFQjUiLCJ2aXNpdG9yX2lkIjoiMjQwMDI5MjY0NDY1MjIyODI3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4fe475a8ac031eae95398fc373a3c1fcb5c0579334e546c6b7e25b8c52f982b3 |
| hovercard-subject-tag | issue:526638462 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/NativeScript/8131/issue_layout |
| twitter:image | https://opengraph.githubassets.com/54112c5bbc79b21490c1a435770d46250e7db74ffba06855979038ae23fee86e/NativeScript/NativeScript/issues/8131 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/54112c5bbc79b21490c1a435770d46250e7db74ffba06855979038ae23fee86e/NativeScript/NativeScript/issues/8131 |
| og:image:alt | Why? Provide an automated way to migrate imports and require statements from: tns-core-modules to @nativescript/core; and nativescript-angular to @nativescript/angular. How? The above can be achiev... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sis0k0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4d375b6c612de26fd037e0638eaf57e32cf9b16daf53ab68c25c04cd3b058113 |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9af1d97e0cdcced8d2b1d10d909b84c76e62924a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width