Eslint: Set pattern for global variables - eslint

We working with a form management system as a base for creating forms. It also includes some helper functions to interact with these forms.
One thing is the generation of global variables for each field like $SURNAME. It has always the same schema. Besides the problem that the list of global variables is very long, the name could also change. Therefore it will be a big effort to add and maintain them in the eslint config file.
I search for a way to define a pattern to ignore these variables from being checked without deactivating the whole no-undef rule.

Related

Robot framework can I reuse test cases with multiple interfaces

I have a lot of high level test cases.
I have the same keywords implemented for:
CLI (telnet)
WEB
Is there an easy way to run those test cases by not duplicating files, just passing a command line argument or something similar - to run these test cases for both CLI and WEB?
This problem can be solved in different ways and much depends on how you want to structure your test case base and scripts.
Start application. If you have specific resource files for your Web and CLI keywords with the same keyword names for the same checks/processing then remove the unwanted files before you start Robot.
Custom Import Keyword In addition to importing a resource file in the Settings section you can also import a resource file through a keyword: Import Resource. This has the added advantage that you can use variables to create the file reference. For example if you have a global with Web/CLI and seperated the files using a directory, then this can be the folder name reference.
Test Case Tagging By duplicating your test cases you can load all the keywords for CLI and Web. Their keywords should be unique, otherwise they will conflict. By adding Test Case tags you can utilize the tag filter feature when starting Robot to run only those test cases that have and/or lack certain tags.
Given that your test cases are unique test cases in the sense that they test different UI's I'd be enclined to seperate at test case level and use tags. Though there isn't a right or wrong way if you make a conscious decision.
As this closely relates to a solution maintaining settings for different environments, please keep that in mind as well.

How to bind user defined extraction rule dynamically in WebTest?

Apart from "Promote Dynamic parameter to webtest parameter"(which binds session key only),
Can we able to bind fetchgriddata=>grid name,execute grid action,etc? for which extraction rules are user defined.
Immediately after a test is recorded, Visual Studio asks whether it should "Promote dynamic parameters to webtest parameters". If you are not sure then answering "Yes" is normally best. After recording and promoting dynamic parameters the test can be further customized (i.e. made to work). One of the tools is the use of extraction rules and then using the extracted values in later parts of the test.
The way that promoting dynamic parameters to webtest parameters works is by creating extraction rules and inserting the values where needed. This automated detection of dynamic data finds many things but it does not (and I think it can not) find all dynamic data items. Hence the test author often needs to find other dynamic data items.
Back on the details of the question. You cannot add extraction rules to a web test before "Promote dynamic parameters to webtest parameters" is asked. Hence the values in your extraction rules cannot be automatically bound into the test.
See also this page which has some more details.

What is the best practice for overriding strings in Orchard CMS?

I often have the situation where the wording of specific strings from various modules or core features needs to be changed for specific tenants & themes in Orchard CMS.
For example, I may have a client that prefers to have the shopping cart checkout button say "Checkout Now" rather than "Go to checkout" which is a string contained within a view in a shopping module.
I can simply override the razor view in my theme and change the string, however views often are quite complex, and it doesn't feel right overriding a view just to change one string.
Another approach I have tried is to define a po translation file within my theme to override the string from the module. This works because the strings in the module are defined using the T() syntax. However, I've noticed that as soon as I define an override for a string within my theme, this override effects all tenants, instead of just the one tenant that has this theme enabled. I'm inclined to think that translations within modules/themes should be ignored from tenants where they are not enabled.
So I'm left wondering what the best approach for this scenario is?
The localisation/po file approach would be ok if tenants ignored po files from themes that aren't enabled, but then again, it would be really nice if there was a module or feature in core that allowed you to specify string overrides via the admin interface. I guess it's more of a "rewording" task than a "translation" task.
The preferred way of doing this is through template overrides. If you don't want to do that, you can actually break shapes down, and delegate the rendering to smaller templates that are easier to override. This is done by simply refactoring the part of a template that you want to be able to override individually into a separate template. This post explains how to do that: http://weblogs.asp.net/bleroy/creating-shapes-on-the-fly
If you're not willing to do that, you can use this module to get strings from the database instead of po files: http://gallery.orchardproject.net/List/Modules/Orchard.Module.Q42.DbTranslations It should be possible to modify it to fit your sceanrio.

TypeScript extend object in module

What I want to do is really similar to this and this except I'm trying to figure out how to put an ArrayExtension inside a module.
I'm trying to get something similar to the way C# extension methods work, that way I can just import the module and I'll have my extra methods. The links I provided show how to extend an existing object, but I haven't been able to figure out how to encapsulate that into a module.
If you're targeting non-browser environments like node.js this will be possible because you will be able to pass references to your module's global members, such as Array, to other modules. Those other modules can then extend the passed in object and/or its prototype with extra functionality which will be only accessible by the calling module. Other modules would have to do the same in order to get these extensions; therefore, conflicts are minimized since imports are explicit.
However, in browser environments this is not the case since there is only one window object and any changes to its members are available everywhere. As soon as any of your modules extended Array those extensions would be available to all other modules -- increasing the possibility for conflicts and making the code harder to reason about.
With that said, there are patterns in JS, and therefore TypeScript, which should accomplish what you want. One such pattern is the 'mixin' pattern which allows you to add on extra functionality on an object instance basis. You could separate re-usable code into mixin modules which could then be applied to an object when needed, or even automatically in constructors. Take a look at this for a decent overview and implementation examples: http://javascriptweblog.wordpress.com/2011/05/31/a-fresh-look-at-javascript-mixins/
If you're trying to extend the built in Array type you can't do that within a module. You're extension will need to live in an ArrayEx.ts file and occur outside of any modules. The reason for that is that if you did it within a module you'd be extending the Foo.Array type which isn't the same as Array.
But you said you just want to be able import the module to have your extra methods show up and all you really need to do is add a /// <reference path='ArrayEx.ts' /> to any file you want the extension methods to be available to. This is essentially the same thing.

When to use explicit string or from a constant string

In terms of strings I understand the need to have strings am going to reuse overname wrapped away somewhere in an XML file or configuration section for strings such as Company Name.
The problem am having with this is where to draw the line on using configuratioh or locally expressed strings?
What decides whether to have the string content wrapped away in a configuration file or to just have the string assigned there and then in a method?
Where am corporate branding a site then yes any corporate aspect strings I will put in a configuration file. Other aspects such as file locations etc will also go in a configuration file.
However, I have found myself discussing with others when I do this as oppose to having an explicit string defined within a method.
Do you have certain criteria that define when to use strings from a configuration section as opposed to being explicitly defined in a method?
Use configuration when you need to be able to change functionality without redeploying/recompiling.
If your string is reused within your application but the functionality involved is not something you want to be configurable, use a constant.

Resources