@admc.com/eslintplugin-sn-test 3.10.0 → 3.11.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.
Files changed (34) hide show
  1. package/bad1Scripts/global/sys_atf_step_config.description_generator/es12.js +4 -0
  2. package/bad1Scripts/global/sys_atf_step_config.description_generator/nonimmedIife.js +7 -0
  3. package/bad1Scripts/global/sys_atf_step_config.description_generator/ootbBoilerplate.js +7 -0
  4. package/bad1Scripts/global/sys_atf_step_config.description_generator/scopedExpr.js +1 -0
  5. package/bad1Scripts/global/sys_atf_step_config.step_execution_generator/ootbBoilerplate.js +55 -0
  6. package/bad1Scripts/global/sys_script_email/wrongIifeParams.js +1 -1
  7. package/bad1Scripts/global/sysevent_in_email_action/ootbBoilerplate.js +4 -0
  8. package/bad1Scripts/scoped-es12/sysevent_in_email_action/ootbBoilerplate.js +6 -0
  9. package/bad1Scripts/scoped-es5/sp_widget.script/globalLog.js +1 -0
  10. package/bad1Scripts/scoped-es5/sys_script/brCurrentUpdate.js +1 -0
  11. package/bad1Scripts/sss_scoped-es12/sys_variable_value/noIife.js +2 -0
  12. package/bad2Scripts/sss_global/sys_variable_value/ootbBoilerplate.js +91 -0
  13. package/goodScripts/all/sp_widget.client_script/cleanedBoilerplate.js +0 -1
  14. package/goodScripts/global/sys_atf_step_config.description_generator/expr.js +1 -0
  15. package/goodScripts/global/sys_atf_step_config.description_generator/nice.js +3 -0
  16. package/goodScripts/global/sys_atf_step_config.step_execution_generator/cleanedBoilerplate.js +4 -0
  17. package/goodScripts/global/sys_atf_step_config.step_execution_generator/nice.js +4 -0
  18. package/goodScripts/global/sysevent_in_email_action/cleanedBoilerplate.js +3 -0
  19. package/goodScripts/scoped-es12/sys_atf_step_config.step_execution_generator/nice.js +4 -0
  20. package/goodScripts/scoped-es12/sysevent_in_email_action/cleanedBoilerplate.js +4 -0
  21. package/goodScripts/scoped-es5/sp_widget.script/good.js +1 -0
  22. package/goodScripts/scoped-es5/sys_processor/scopedLogging.js +1 -0
  23. package/goodScripts/scoped-es5/sys_script/glideDateDV.js +1 -0
  24. package/goodScripts/scoped-es5/sys_script/good.js +1 -0
  25. package/goodScripts/scoped-es5/sys_script_email/good.js +1 -0
  26. package/goodScripts/scoped-es5/sys_transform_map/good.js +3 -2
  27. package/goodScripts/sin_scoped-es12/sys_variable_value/sysid.js +3 -0
  28. package/goodScripts/sss_global/sys_variable_value/cleanedBoilerplate.js +4 -0
  29. package/goodScripts/sss_scoped-es12/sys_variable_value/cleanedBoilerplate.js +4 -0
  30. package/goodScripts/sss_scoped-es12/sys_variable_value/safeNoIife.js +20 -0
  31. package/goodScripts/sss_scoped-es12/sys_variable_value/sysid.js +24 -0
  32. package/goodScripts/sss_scoped-es12/sys_variable_value/useGlobals.js +23 -0
  33. package/package.json +2 -4
  34. package/sneslintrc.json +5 -4
@@ -0,0 +1,4 @@
1
+ (function() {
2
+ "use strict";
3
+ return `I am ${gs.getUserName()}`;
4
+ })();
@@ -0,0 +1,7 @@
1
+ function generateDescription() {
2
+ "use strict";
3
+ // the global variable 'step' represents the current glide record
4
+ var description = "X";
5
+ return description;
6
+ }
7
+ generateDescription();
@@ -0,0 +1,7 @@
1
+ function generateDescription() {
2
+ // the global variable 'step' represents the current glide record
3
+ var description = "X";
4
+ // your code here
5
+ return description;
6
+ }
7
+ generateDescription();
@@ -0,0 +1 @@
1
+ `I am ${gs.getUserName()}`;
@@ -0,0 +1,55 @@
1
+ // The inputs are a map of the variables defined in the inputs related list below.
2
+ // Inputs are consumed in the step configuration. Input
3
+ // values may be hardcoded or mapped from the outputs of a previous step.
4
+ // If a test author using your step uses mapping to pass in an output from a previous
5
+ // test step then when referencing the input variable the mapping will be resolved
6
+ // automatically
7
+ // Example:
8
+ // var myRecords = new GlideRecord(inputs.table);
9
+ //
10
+ // The outputs are a map of the variables defined in the outputs related list.
11
+ // Outputs should be set (assigned) in order to pass data out of a test step that
12
+ // can be consumed my mapping as an input to subsequent steps.
13
+ // Example:
14
+ // outputs.table = gr.getRecordClassName()
15
+ //
16
+ //
17
+ // Note that inputs and outputs are strongly typed as defined in their variable definition.
18
+ // Their behavior is the same as a dictionary defined field of the same type in a table.
19
+ //
20
+ // The stepResult is a simple API for controlling the step pass/fail and logging with three
21
+ // methods:
22
+ // stepResult.setFailed: Causes step to fail
23
+ //
24
+ // stepResult.setSuccess: Causes step to succeed
25
+ //
26
+ // stepResult.setOutputMessage: Log a message to step results after step executes.
27
+ // Can only be called once or will overwrite previous
28
+ // message
29
+ //
30
+ // If neither setFailed or setSuccess is called the default is to succeed.
31
+ //
32
+ // Example usage of step timeout in script
33
+ // var counter = 0;
34
+ // // 'timeout' is a field on the step form
35
+ // while (counter <= timeout) {
36
+ // if (desiredOutcome) {
37
+ // stepResult.setOutputMessage('Success!');
38
+ // stepResult.setSuccess();
39
+ // return;
40
+ // }
41
+ // counter++;
42
+ //
43
+ // // When writing scripts in ATF, use waitOneSecond() instead of gs.sleep()
44
+ // // since gs.sleep() may not work in non-global scopes
45
+ // sn_atf.AutomatedTestingFramework.waitOneSecond();
46
+ // }
47
+ //
48
+ // // desired outcome did not occur within the timeout
49
+ // stepResult.setOutputMessage('Failure!');
50
+ // stepResult.setFailed();
51
+ //
52
+ (function executeStep(inputs, outputs, stepResult, timeout) {
53
+ gs.log("Input params: " + inputs + " / " + outputs + " / " + stepResult + " / " + timeout,
54
+ "src");
55
+ }(inputs, outputs, stepResult, timeout));
@@ -1,3 +1,3 @@
1
1
  (function() {
2
2
  gs.log("global log", "src");
3
- })(current, template, email, email_action, event, gs);
3
+ })(current, template, email, email_action, event, other);
@@ -0,0 +1,4 @@
1
+ (function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
2
+ logger.log("Input params: " + current + " / " + event + " / " + email + " / " + classifier);
3
+ // Implement email action here
4
+ })(current, event, email, logger, classifier);
@@ -0,0 +1,6 @@
1
+ (function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
2
+ "use strict";
3
+
4
+ // Implement email action here
5
+ logger.info(`Input params (${current}) (${event}) (${email}) (${classifier})`);
6
+ })(current, event, email, logger, classifier);
@@ -1,4 +1,5 @@
1
1
  (function() {
2
+ "use strict";
2
3
  if (input.datum) {
3
4
  data.datum = input.datum;
4
5
  gs.log("Set datum for client", "src");
@@ -1,3 +1,4 @@
1
1
  (function() {
2
+ "use strict";
2
3
  if (!current.update("update notation")) throw new Error("update failed");
3
4
  })(previous, current);
@@ -0,0 +1,2 @@
1
+ const aStr = "thing";
2
+ gs.info(aStr);
@@ -0,0 +1,91 @@
1
+ // You can use this step to execute a variety of server-side javascript tests including
2
+ // jasmine tests and custom assertions
3
+ //
4
+ //
5
+ // Pass or fail a step: Override the step outcome to pass or fail. This is ignored
6
+ // by jasmine tests
7
+ //
8
+ // - Return true from the main function body to pass the step
9
+ // - Return false from the main function body to fail the step
10
+ //
11
+ //
12
+ // outputs: Pre-defined Step config Output variables to set on this step during
13
+ // execution that are available to later steps
14
+ //
15
+ // steps(SYS_ID): A function to retrieve Output variable data from a step that executed
16
+ // earlier in the test. The desired step's sys_id is required
17
+ //
18
+ // params: The current test run data set's parameter data including both
19
+ // exclusive and shared parameters
20
+ //
21
+ // Example:
22
+ //
23
+ // // Test step 1 - add data
24
+ // var gr = new GlideRecord('sc_task');
25
+ // // If parameterized testing is enabled, parameters are stored in the params object
26
+ // gr.setValue('short_description', params.u_my_short_description)
27
+ // gr.setValue('caller', params.u_my_user.manager)
28
+ // // this sample step's Step config has Output variables named table and record_id
29
+ // outputs.table = 'sc_task';
30
+ // outputs.record_id = gr.insert();
31
+ //
32
+ // // Test step 2 - access added data and validate
33
+ // // check that the record exists (or that business logic changed it)
34
+ // var gr = new GlideRecord("sc_task");
35
+ // gr.get(steps(PREVIOUS_STEP_SYS_ID).record_id);
36
+ // assertEqual({name: "task gr exists", shouldbe: true, value: gr.isValidRecord()});
37
+ //
38
+ //
39
+ // stepResult.setOutputMessage: Log a message to step results after step executes.
40
+ // Can only be called once or will overwrite previous
41
+ // message
42
+ //
43
+ // Example:
44
+ //
45
+ // var gr = new GlideRecord('sc_task');
46
+ // gr.setValue('short_description', 'verify task can be inserted');
47
+ // var grSysId = gr.insert();
48
+ // var justCreatedGR = new GlideRecord('sc_task');
49
+ // if (justCreatedGR.get(grSysId)) {
50
+ // stepResult.setOutputMessage("Successfully inserted task record");
51
+ // return true; // pass the step
52
+ // } else {
53
+ // stepResult.setOutputMessage("Failed to insert task record");
54
+ // return false; // fail the step
55
+ // }
56
+ //
57
+ //
58
+ // Note: describe is only supported in Global scope.
59
+ // Use 'describe' to create a suite of test scripts and 'it' to define test expectations
60
+ //
61
+ // Example jasmine test:
62
+ //
63
+ // describe('my suite of script tests', function() {
64
+ // it('should meet expectations', function() {
65
+ // expect(true).not.toBe(false);
66
+ // });
67
+ // });
68
+ // // make sure to uncomment jasmine.getEnv().execute(); outside the function body
69
+ //
70
+ //
71
+ // assertEqual: A function used to compare that assertion.shouldbe == assertion.value;
72
+ // in case of failure it throws an Error and logs that the assertion by
73
+ // name has failed
74
+ //
75
+ // Example:
76
+ //
77
+ // var testAssertion = {
78
+ // name: "my test assertion",
79
+ // shouldbe: "expected value"
80
+ // value: "actual value",
81
+ // };
82
+ // assertEqual(testAssertion); // throws Error, logs message to test step output
83
+ //
84
+ (function(outputs, steps, params, stepResult, assertEqual) {
85
+ // add test script here
86
+ gs.log("Input params: " + outputs + " / " + steps + " / " + params + " / " + stepResult
87
+ + " / " + assertEqual, "src");
88
+
89
+ })(outputs, steps, params, stepResult, assertEqual);
90
+ // uncomment the next line to execute this script as a jasmine test
91
+ //jasmine.getEnv().execute();
@@ -1,5 +1,4 @@
1
1
  api.controller=function() {
2
- // Doing this instead of eslint-disable notation since that notation would conflict with wrapping:
3
2
  "use strict";
4
3
  // This is as close as can get to OOTB while not failing more basic rules that we don't
5
4
  // want to test for here.
@@ -0,0 +1 @@
1
+ "I am " + gs.getUserName();
@@ -0,0 +1,3 @@
1
+ (function() {
2
+ return "I am " + gs.getUserName();
3
+ })();
@@ -0,0 +1,4 @@
1
+ (function executeStep(inputs, outputs, stepResult, timeout) {
2
+ gs.log("Input params: " + inputs + " / " + outputs + " / " + stepResult + " / " + timeout,
3
+ "testing");
4
+ }(inputs, outputs, stepResult, timeout));
@@ -0,0 +1,4 @@
1
+ (function(inputs, outputs, stepResult, timeout) {
2
+ gs.log("Input params: " + inputs + " / " + outputs + " / " + stepResult + " / " + timeout,
3
+ "src");
4
+ })(inputs, outputs, stepResult, timeout);
@@ -0,0 +1,3 @@
1
+ (function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
2
+ logger.log("Input params: " + current + " / " + event + " / " + email + " / " + classifier);
3
+ })(current, event, email, logger, classifier);
@@ -0,0 +1,4 @@
1
+ (() => {
2
+ "use strict"; // eslint-disable-next-line array-callback-return
3
+ ["u_a", "u_b", "u_c"].forEach(n => outputs[n] = inputs[n]);
4
+ })(inputs, outputs, stepResult, timeout);
@@ -0,0 +1,4 @@
1
+ (function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
2
+ "use strict";
3
+ logger.info(`Input params (${current}) (${event}) (${email}) (${classifier})`);
4
+ })(current, event, email, logger, classifier);
@@ -1,4 +1,5 @@
1
1
  (function() {
2
+ "use strict";
2
3
  if (input.datum) {
3
4
  data.datum = input.datum;
4
5
  gs.info("Set datum for client" + input.datum);
@@ -1,4 +1,5 @@
1
1
  (function() {
2
+ "use strict";
2
3
  gs.debug("Single-param");
3
4
  gs.info("Multi-{1} with {0} placeholders", 2, "param");
4
5
  var dynamicMsg = "Does not contain placeholders";
@@ -1,4 +1,5 @@
1
1
  (function() {
2
+ "use strict";
2
3
  // This is the supported replacement for obsoleted gs.now() function:
3
4
  gs.info("Today in UTF is " + new GlideDate().getDisplayValue());
4
5
  })(previous, current);
@@ -1,4 +1,5 @@
1
1
  (function() {
2
+ "use strict";
2
3
  // Test availability of scoped vars from the different component lists:
3
4
  gs.info(new sn_ws_err.NotAcceptableError("fake err")); // coreServerObjects.txt
4
5
  gs.info(Object.keys(new sn_codesearch.CodeSearch()).length); // SIScopes
@@ -1,3 +1,4 @@
1
1
  (function(thing) {
2
+ "use strict";
2
3
  gs.info(thing);
3
4
  })(email, email_action, event, current, template);
@@ -1,3 +1,4 @@
1
1
  (function() {
2
- gs.info("scopedl og");
3
- })(source, target, isUpdate, map, log);
2
+ "use strict";
3
+ gs.info("scoped log");
4
+ })(source, target, map, log, action==="update");
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ const aSysId = "123456789012345678901234567890ab";
3
+ gs.info(aSysId);
@@ -0,0 +1,4 @@
1
+ (function(outputs, steps, params, stepResult, assertEqual) {
2
+ gs.log("Input params: " + outputs
3
+ + " / " + steps + " / " + params + " / " + stepResult + " / " + assertEqual, "src");
4
+ })(outputs, steps, params, stepResult, assertEqual);
@@ -0,0 +1,4 @@
1
+ ((outputs, steps, params, stepResult, assertEqual) => {
2
+ "use strict";
3
+ gs.info(`Input params (${outputs}) (${steps}) (${params}) (${stepResult}) (${assertEqual})`);
4
+ })(outputs, steps, params, stepResult, assertEqual);
@@ -0,0 +1,20 @@
1
+ gs.info(`Provided functions:
2
+ ${jasmine}
3
+ ${describe}
4
+ ${xdescribe}
5
+ ${fdescribe}
6
+ ${it}
7
+ ${xit}
8
+ ${fit}
9
+ ${beforeEach}
10
+ ${beforeAll}
11
+ ${afterEach}
12
+ ${afterAll}
13
+ ${expect}
14
+ ${fail}
15
+ ${pending}
16
+ ${spyOn}
17
+ + input Params:
18
+ ${steps}
19
+ ${params}
20
+ `);
@@ -0,0 +1,24 @@
1
+ ((steps, params) => {
2
+ "use strict";
3
+ gs.info(`Provided functions:
4
+ ${jasmine}
5
+ ${describe}
6
+ ${xdescribe}
7
+ ${fdescribe}
8
+ ${it}
9
+ ${xit}
10
+ ${fit}
11
+ ${beforeEach}
12
+ ${beforeAll}
13
+ ${afterEach}
14
+ ${afterAll}
15
+ ${expect}
16
+ ${fail}
17
+ ${pending}
18
+ ${spyOn}
19
+ + input Params:
20
+ ${steps}
21
+ ${params}
22
+ `);
23
+ gs.info("123456789012345678901234567890ab");
24
+ })(outputs, steps, params, stepResult, assertEqual);
@@ -0,0 +1,23 @@
1
+ ((steps, params) => {
2
+ "use strict";
3
+ gs.info(`Provided functions:
4
+ ${jasmine}
5
+ ${describe}
6
+ ${xdescribe}
7
+ ${fdescribe}
8
+ ${it}
9
+ ${xit}
10
+ ${fit}
11
+ ${beforeEach}
12
+ ${beforeAll}
13
+ ${afterEach}
14
+ ${afterAll}
15
+ ${expect}
16
+ ${fail}
17
+ ${pending}
18
+ ${spyOn}
19
+ + input Params:
20
+ ${steps}
21
+ ${params}
22
+ `);
23
+ })(outputs, steps, params, stepResult, assertEqual);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@admc.com/eslintplugin-sn-test",
3
- "version": "3.10.0",
3
+ "version": "3.11.1",
4
4
  "description": "External tests for ESLint plugin @admc.com/eslint-plugin-sn",
5
5
  "scripts": {
6
6
  "test": "mocha --recursive",
@@ -25,9 +25,7 @@
25
25
  },
26
26
  "homepage": "https://github.com/unsaved/eslint-plugin-sn#readme",
27
27
  "dependencies": {
28
+ "@admc.com/eslint-plugin-sn": "^3.13.1",
28
29
  "mocha": "^10.0.0"
29
- },
30
- "peerDependencies": {
31
- "@admc.com/eslint-plugin-sn": "^3.9.8"
32
30
  }
33
31
  }
package/sneslintrc.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "@admc.com/sn/no-client-gr": "error"
44
44
  }
45
45
  }, { // ES 12 overrides
46
- "files": [ "**/scoped-es12/*.js" ],
46
+ "files": [ "**/scoped-es12/*.js", "**/sys_variable_value/s*_scoped-es12/*.js" ],
47
47
  "rules": {
48
48
  "strict": ["error", "global"],
49
49
  "prefer-arrow-callback": "error",
@@ -63,10 +63,11 @@
63
63
  "prefer-template": "off",
64
64
  "no-template-curly-in-string": "off"
65
65
  }
66
- }, { // Overriding for ES12 IIFE scriptlets}
66
+ }, { // Overriding for ES5+ IIFE scriptlets}
67
67
  "files": [
68
- "**/@(sys_script|sys_ws_operation|sys_web_service|sys_processor|sys_script_email|sys_transform_map|sys_transform_script|sp_widget.script|sys_ui_page.processing_script)/scoped-es12/*.js", // eslint-disable-line max-len
69
- "**/sys_ui_action/@(iso|noniso)_scoped-es12/*.js"
68
+ "**/@(sys_script|sys_ws_operation|sys_web_service|sys_processor|sys_script_email|sys_transform_map|sys_transform_script|sp_widget.script|sys_ui_page.processing_script|sysevent_in_email_action|sys_atf_step_config.step_execution_generator)/scoped-es*/*.js", // eslint-disable-line max-len
69
+ "**/sys_ui_action.script/@(iso|noniso)_scoped-es*/*.js",
70
+ "**/sys_variable_value/sss_scoped-es*/*.js"
70
71
  ],
71
72
  "rules": { "strict": ["error", "function"] }
72
73
  }, { // Custom table and scope