Skip to content

Commit f07b117

Browse files
msaelicesjawa-the-hutt
authored andcommitted
Fix no-def eslint errors with TNS_APP_MODE and TNS_APP_PLATFORM variables (#17)
* Typo fix * Fix no-def eslint errors with TNS_APP_MODE and TNS_APP_PLATFORM variables.
1 parent 2f3cb2d commit f07b117

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Diff for: README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ vue invoke vue-cli-plugin-nativescript-vue
2626

2727
## Invocation Prompts
2828
1. Enter a unique application identifier
29-
* Accpeting the default is fine for testing
29+
* Accepting the default is fine for testing
3030
2. Use HTML5 history mode? (Default: hash mode)
3131
* Required parameter for the cli core generator when vue-router is used
3232
3. Is this a brand new project? (Default: Yes)
33-
* By choosing `No`, the plugin will try and be as non-destructive as possible to an existing project. It will do this by adding a folder into root named `ns-example` and add files into there to provide examples of how a project would change.
33+
* By choosing `No`, the plugin will try and be as non-destructive as possible to an existing project. It will do this by adding a folder into root named `ns-example` and add files into there to provide examples of how a project would change.
3434
* These changes will factor in answers to the other questions and adjust accordingly. Regardless of the answer, the plugin will install packages and adjust `package.json` as necessary to prep the project.
3535
4. Dual Native AND Web development experience or a Native only? (Default: Dual)
3636
* By default, the plugin will assume you want to develop for the Web and Native environments within the same project. As such, there will be two sides to the project where web environments will be actively developed within `/src` and Native environments will be developed within `/app` unless you choose to integrate `Nativescript-Vue-Web` and all files will be placed in `/src`.
37-
* Warning: Choosing to develop for Native only will move the main entry point of the project and development folder to `/app`, it will copy the necessary files and then delete `/src`.
37+
* Warning: Choosing to develop for Native only will move the main entry point of the project and development folder to `/app`, it will copy the necessary files and then delete `/src`.
3838
* By choosing `Dual`, you will be able to bring your own component framework into the web portion of the project. `NativeScript-Vue` [cannot use vue-router](https://nativescript-vue.org/en/docs/routing/vue-router/) currently, so you will have to provide your own manual routing. The templated options deployed with the plugin will show how to do basic manual routing.
3939
5. Use [Nativescript-Vue-Web](https://github.com/Nativescript-Vue-Web/Nativescript-Vue-Web) to develop web components with `Nativescript-Vue` syntax? (Default: No)
40-
* This prompt should only appear if you have chosen to develop in the Dual Web and Native environments.
40+
* This prompt should only appear if you have chosen to develop in the Dual Web and Native environments.
4141
* By chosing `Yes. Use Nativescript-Vue-Web component framework`, it will effecively integrate a web component framework that will allow you to develop components that can be used in the Web and Native side of the project. It uses `NativeScript-Vue` like syntax on components which will allow for the sharing of components between NativeScript and Web.
4242
6. What type of template do you want to start with? (Default: Simple)
4343
* Simple is just a simple setup with a header and basic routing.
@@ -148,6 +148,7 @@ Each time the project is built or served, the plugin will copy the latest webpac
148148

149149
#### Inspecting the Webpack config
150150
If you'd like to see what the webpack config is doing then you can run one of the following:
151+
151152
1. `vue inspect -- --env.android > out-android.js`
152153
2. `vue inspect -- --env.ios > out-android.js`
153154
3. `vue inspect -- --env.web > out-web.js`
@@ -175,9 +176,9 @@ If your CLI 3 project has TypeScript enabled, then the plugin will attempt to gi
175176
There will also be additional `tsconfig.json` files added into the root that allow for specific configurations depending on the type of environment you are building for. You will see a `tsconfig.web.json` and a `tsconfig.native.json` file that extend the base `tsconfig.json` file in root. The plugin's webpack integration will ensure the correct `tsconfig` file is referenced at runtime.
176177

177178
## For Native environment development
178-
It should be noted that the plugin will give you the ability to develop generic SFC's (\*.native.vue) to be used in both Android and IOS, or if you need to differentiate between Android (\*.android.vue) and IOS (\*.ios.vue) then you can change the SFC's extension to map to the environment you choose.
179+
It should be noted that the plugin will give you the ability to develop generic SFC's (\*.native.vue) to be used in both Android and IOS, or if you need to differentiate between Android (\*.android.vue) and IOS (\*.ios.vue) then you can change the SFC's extension to map to the environment you choose.
179180

180-
At `serve` or `build` in conjunction with the mode such as `android` or `ios`, it will filter which files are looked at. For instance, if you do `npm run serve:android`, then it will look for `*.native.vue` and `*.android.vue` files and ignore `*.ios.vue` files entirely. Conversely, it will do the same when your are doing the same for `ios` and will ignore `*.android.vue` files.
181+
At `serve` or `build` in conjunction with the mode such as `android` or `ios`, it will filter which files are looked at. For instance, if you do `npm run serve:android`, then it will look for `*.native.vue` and `*.android.vue` files and ignore `*.ios.vue` files entirely. Conversely, it will do the same when your are doing the same for `ios` and will ignore `*.android.vue` files.
181182

182183
This will allow you to develop generic native components under the `*.native.vue` file extension, but in special cases, it may require you to do platform specific components. Use the corrosponding file extension to allow this to happen.
183184

Diff for: generator/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ module.exports = async (api, options, rootOptions) => {
191191
});
192192
}
193193

194+
// if the project is using eslint, add some global variables
195+
// to the eslintConfig in order to avoid no-def errors
196+
if (api.hasPlugin('eslint')) {
197+
api.extendPackage({
198+
eslintConfig: {
199+
globals: {
200+
"TNS_APP_MODE": true,
201+
"TNS_APP_PLATFORM": true
202+
}
203+
}
204+
})
205+
}
206+
194207
console.log('deleting from package.json');
195208
api.extendPackage((pkg) => {
196209
// if the project is using babel, then delete babel-core

0 commit comments

Comments
 (0)