Implement new linter checks
See original GitHub issueThis project is aimed at writing linters for the checks below. (Note that, per @Hudda’s audit in May 2020, all checks in this issue would need custom extensions to be developed.) The general procedure to write such linters is as follows:
-
Look at the sample code in the linked issue for the affected area.
-
Think about character by character, word by word, or line by line what would convince you that there is an error.
-
If it is in a Python file, check whether there is already a built-in pylint rule that can detect this. If not, you’ll need to write a Pylint extension…
-
See wiki page for information on writing lint checks.
-
See this page for information on writing pylint extension.
-
Run
python -m scripts.run_backend_tests --test_target=scripts.linters.pylint_extensions_test
for testing pylint extension against your tests.
A few general guidelines while writing such tests:
- Try to look at the existing checks to see how others have approached the issue.
- Look to see if there are existing lint checks out there that can be modified.
To get started, ask to be assigned to any unclaimed task. Tasks are claimed by adding the username of the claimer to the end of the task, e.g. @example
.
Python
- Enforce multiples of 4 indentation in docstring (#8165)
- Check for proper comment indentation (#6422)
- Add check for proper Args and Returns style, including typeinfo (#6095) @Hudda
- Add check to multiline expressions ensuring line break after ‘(’ (#6495) @Hudda
- Check for args-name for a non-keyword argument (#6067) @Hudda
- Add check to ensure that pylint pragmas are used to disable any rule for a single line (#5477) @Hudda
- Add lint check to ensure that there is an empty line between imports and fileoverview (#7830) - @donosco98
- Add lint check to ensure that there is one blank newline below each class docstring. @Hudda
- Detect variables that are declared but never used. @Hudda
- Forbid usage of assertRaises; require assertRaisesRegexp instead. @Hudda
- Enforce that PEP8 naming convention is followed. Please check the comment here to understand the use case. @sajalasati
- Check that functions with
test_only
in their names are only used in_test.py
files. @anmol1point0 - Add check for excessive new lines between function definition in a class. (comment another comment)
- Add check for newline above Args, Raises and Returns.
- Forbid use of “if x != None” (prefer “if x is not None” instead) (#11108) @michaelw54
- Add a lint check to ensure that there is a single space between
if
,elif
,while
and bracket (#10486) @EricZLou - Add a lint check to ensure that the type info of *args should be
list(*)
. - Add a lint check to ensure newline after the
Args:
,Returns:
,Raises:
,Yields:
in docstrings. (@MegaMind77-coder found that the check already happens via some other method - see this comment) - Add a lint check to ensure that there are no blank lines below the function definition. @kingjuno
- Add a lint check to prevents usage of string concatenation, and promotes string interpolation instead. (This is a coding style guideline of the Oppia codebase - see 4th bullet point here) @tanishq67
- All docstrings must end with a full stop. (Inspect if we already have this check or not - if we have it then here it was not caught, and if we don’t have it then find a way to enable/implement it) @tanishq67
- Check to enforce use of Args, Returns and Raises in the docstring. (see explanation here; Depends on #11776 to be completed first)
- Every comment should have a single space after it (so, no “#pylint: …”) (Note we already have a single line comment checker, but not sure why this check isn’t catching it) @esmith36
- Prohibit usage of trailing comments (except for pylint pragmas) - (comment) @sajalasati (PR #13681)
Every new JS/TS lint check will be implemented in scripts/linters/custom_eslint_checks/rule/
directory if there is no eslint plugin available for that purpose.
JS/TS
- Add a check to ensure that multi-line expressions in parenthesis are broken down after “(” in JavaScript files (#6047) @Hudda
- Check for unused directive/service dependencies (#5611) @Hudda
- Improve reachability of sorted imports (#6513) @Hudda
- Check for eslint-disable statements (#6446) @Hudda
- Lint check for test files (#5879) @Hudda
- Detect variables that are defined but never used (https://github.com/oppia/oppia/pull/9202#discussion_r418997633). @Hudda
- Forbid use of innerHTML due to security issues (see https://github.com/oppia/oppia/pull/8755/files#diff-53372eb49ce2e739c250a7b1c1e98f6dR43 for an example)
- Check for unused imports (see https://github.com/oppia/oppia/pull/8658#discussion_r390046450)
- There should be no space before “function” (see https://github.com/oppia/oppia/pull/8682#discussion_r392562066) @Hudda
- Catch missing space after semicolon: https://github.com/oppia/oppia/pull/8738#discussion_r403828123 @Hudda
- Add lint check to ensure use of newline after ‘(’ in a multiline function.
- Check for unused args in method signatures and remove them (or keep them but prefix with “unused”, e.g. for changeDict here) @kizjkre
- Add lint check to ensure require(…) statements are alphabetized (#6748) @luccasparoni
- Add eslint check to ensure space between
type
and:
[e.g:const variableName:<space>TYPE
] (comment.) @YBCS (#12222) - Add a lint check to ensure there is exactly 1 blank line between each test case. (See comment for ref) @Aman9795
- All $http calls should be in backend-api files and prohibited elsewhere (#8039)
- Add lint check for 2-space indentation in class body [#8402 comment] (ref)(https://github.com/oppia/oppia/pull/8519#discussion_r410513440)
- Add lint check to ensure that functions are called with the right number of args (e.g. we should catch cases where foo() is called as
foo(a)
). - Add lint check to ensure that functions with “testOnly” in their names are only called from “spec” files. @rodemore
- Add lint check to remove unnecessary require from the codebase (comment)
- Add check to ensure that eslint pragma are used to disable any rule for a single line. (comment) #10497
- Add eslint check for spacing in the curly brackets. See(#8128 for more details) @Mayank-gaur
- Add lint check to ensure that all async functions’ names end with “Async”, and that all functions that end with “Async” are tagged as async.
- Add lint check to ensure that all private functions/variables names start with
_
, and that all functions/variables that start with_
are tagged asprivate
(in TypeScript). @shubhamcodez - Prevent spaces between typecasts and variable names (see e.g. https://github.com/oppia/oppia/pull/11410/files/7d872eeb1a42fc23215cac2e296e468ab8bbae88..cdba3fe9653ac2e0c8a4e81be6e4dd0da2bfe65f#diff-3c4de5677e4c7d7363f327115b622002d2522a474d07ed19422d3810b15b9ec9R136)
- Add a lint check to break after ‘(’, not ‘=’. https://github.com/oppia/oppia/pull/12944#discussion_r645953549
- Add a lint check to indent by 2 spaces if you break to a newline. https://github.com/oppia/oppia/pull/12944#discussion_r645953549
E2E tests (Not available – Reserved for GSoC)
- #13215 @AdityaDubey0
- Not using await for .first(), .last(), or .get(i) calls on ElementArrayFinder objects @AdityaDubey0
- Making sure all root element selectors use HTML classes that start with “protractor-test-”, e.g. element(by.css(‘.protractor-test-parent-element’)).element(by.css(‘.class-of-element-you-cannot-change’)) @AdityaDubey0
- Keep element selectors at the tops of files. Where selectors cannot be defined at the top of the file, define locators at the top.
- Do not define element selectors in any files outside of
protractor_utils/
orextensions/
- Only select elements using
by.css(...)
CSS
- Check for alphabetized list in CSS (#8171 ) @Hudda
- Prohibit inline styling (#6212) @Hudda
- Restrict use of px with 0. (comment) (#12285) @pawan9116 (#12285)
- Use 3 character hexadecimal notation for color where possible. - See an example here - (#12282) @tanishq67
HTML
- Check for space before and after = (comment) @aasiffaizal (#12225)
CODEOWNERS
- Ensure that CODEOWNERS lines do not have any comments after the line. comment - (#11835)
- Have codeowners lint check saying if a line is completely superseded (and therefore redundant)
Other
- Add check to ensure that all lines in skip_files in app.yaml reference valid files in the repository (see this line). @Hudda
- Add newline check at end of file (#8252) @Hudda
- Add lint checks to ensure that there are valid spaces and newlines (#7301) @Hudda
- Lint checks for webpack config (#7414) @Hudda
- Check that all TODO comments start with capital letter (#7182) @Hudda
- Check for proper comment style for Python and JS files (#6163) @Hudda
- Ensure that every file (of any type) ends with exactly one newline character. @Hudda
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:321 (230 by maintainers)
Top GitHub Comments
@kingjuno I’ve assigned you.
@kingjuno modify
BlankLineBelowFileOverviewChecker