Documentation for fdk skip validation

Is there any more documentation on how to skip specific validations in fdk?

 fdk help validate

  validate: # Run validation tests on the app

  Options:

    -d, --app-dir        App directory.
    -v, --skip-validation Skip specific validations.
    -h, --help           run command help.
    -f, --fix            automatically fix validation warnings and errors

Also, is it possible to increase the complexity score threshold at which a function is flagged? Sometimes it flags a function which I feel is perfectly reasonable but I don’t like to have to see the warning every time I run.

Understood, @stevemc .

Please try out this command to skip validations. Not that this should be used for development purposes only. It is highly recommended to go without skipping validation for production use of the app by users.

fdk run --skip-validation lint

This is an interesting ask, Can you please create a Feedback Topic?

But currently, we don’t have this option. Thanks for bringing this up. It sparks our perspective towards developer experience.

1 Like

Thanks for the info. I’m not clear what ‘lint’ does - I guess it just skips formatting errors but not code errors?

I use Sublime text editor for python dev and there I can indicate specific lint errors to ignore. Fortunately FDK foes not implement all lint errors or I’d certainly be going crazy! But I was hoping for something similar where I can indicate specific errors to ignore.

Here are a couple examples:

[WARN] app/scripts/app.js::107: 'contact' declared and assigned in different scopes. Possible asynchronous race condition.

If I review and feel the possibility of a race condition is so remote I’m willing to live with it, can I then mark this code line in some way to ignore it? I do like to be warned about this but then I’d like to suppress if I review.

Second, I get warned a lot about functions that have unused variables. For example in fixed callbacks where I don’t have a need for the passed variable. Or in error handling where I just want to write a simple log.

FDK validate is great - I’m thankful for it. SO I don’t like to ask for more. This is not a make or break issue - I can live with it. But I am a bit of a Type A person and so I find myself struggling to get rid of all the errors :frowning:

posted other topic here:

It appears like Freshworks CLI uses ESLint behind the scenes. So partly, the validation that will be skipped is more than just the formatting level — static checking.

This is not a official suggested way to do this. But you can try. Given that Freshworks CLI uses ESLint for lint checking I am hoping the following should work,


/* eslint-disable require-atomic-updates */

The comment above will disable the warning thrown about race conditions JS code here on.

// eslint-disable-line require-atomic-updates

The above comment will disable the warning thrown only on a specific line of code that causes race condition.

Similarly for complexity:

/*eslint-disable complexity: ["error", 2]*/

function a(x) {
    if (true) {
        return x;
    } else {
        return 4;
    }
}

function b() {
    foo ||= 1;
}

Example

I just tried this for following simple code snippet,

async function getTicketsInfo() {
  var client = await app.initialized(); 
}

Run fdk validate it will log the following to the console:

Validation failed due to the following issue(s):
[ERROR] app.js::10: 'client' is assigned a value but never used.

I was able to disable this by

async function getTicketsInfo() {
  var client = await app.initialized(); // eslint-disable-line no-unused-vars
}

// fdk validate
❯ fdk validate
Validation Successful

There might be a lot of other rules you may want to disable for your app development. Here is the reference to the rules: List of available rules - ESLint - Pluggable JavaScript linter. Nevertheless, to say, it is recommended to address some of these hints as you prepare to deploy to production.

Very nice! Thanks. I love the ability to put inline suppression on specific items.

The “-disable” did not work for compexity. What worked was changing complexity like this:

/*eslint complexity: ["error", 9]*/

It looks like regardless of where you put the comment, it impacts complexity in entire file. You cannot do this for a single function.

For suppressing errors, eslint-disable or eslint-disable-line did not work for me. what worked for me was this:

 /*eslint-disable */
// Some code that generates errors or warnings here 
/*eslint-enable */

Note: regarding the race conditions. Turns out it was bad coding :slight_smile: I was not using strict mode and I had local variables assigned w/o declaring in a function. After adding strict to every function, errors became obvious.

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.