Skip to content

Lint configuration source annotations #57193

Closed
@pq

Description

@pq

Ideally, disabling lints will piggyback on a general method to disable warnings via source annotations in the analyzer. Pending resolution there, and perhaps to encourage it, this ticket is meant to kick off the conversation specific to disabling linting (but really about configuring the analyzer in general).

By way of a motivational example, take the following.

class BoxBad {
  var _contents;
  get contents => _contents;
}

which triggers a lint suggesting we should prefer a public final field to a getter in this instance. Suppose, just this once, we'd like to suppress that warning. How would that look?

Some prior art to get the juices flowing.

eslint

/*eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/*eslint-enable no-alert */

alert('foo'); // eslint-disable-line

jscs

// jscs:disable requireCurlyBraces
if (x) y(); // all errors from requireCurlyBraces on this line will be ignored
// jscs:enable requireCurlyBraces
if (z) a(); // all errors, including from requireCurlyBraces, on this line will be reported

jshint

/* jshint undef: true, unused: true */

// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be ignored by JSHint.
/* jshint ignore:end */

ignoreThis(); // jshint ignore:line

pylint

# pylint: disable=unused-argument
print self\
    + "foo"

RubyCop:

# rubocop:disable Metrics/LineLength, Style/StringLiterals
[...]

for x in (0..19) # rubocop:disable Style/AvoidFor

stylecop

[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed. Suppression is OK here.")] 
public class MyUndocumentedClass 
{ 
    public void MyUndocumentedMethod 
    { 
    } 
}

tslint

/* tslint:disable */
/* tslint:disable:rule1 rule2 rule3... */ 
[…]

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions