Repository: oppia/oppia

Issue:
Lint checks should catch 'xdescribe' and 'xit'
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**
Currently, lint checks looks only for `fdescriibe` and `fit`.
It should also catch and throw an error message in case of `xdescribe` and `xit`.
This is critical because I've managed to **bypass pre-commit lint checks** using this method.
This will cause unnecessary difficulties in the development life cycle.
**To Reproduce**
Steps to reproduce the behavior:
 1. Go to any one of the .spec files
 2. use `xdescribe` or `xit`

**Observed behavior**
Pre-commit lint checks failing to catch `xdescribe` and `xit`

**Expected behavior**
Pre-commit lint checks should catch `xdescribe` and `xit`

**Screenshots**
![Screenshot from 2021-04-01 03-08-28](https://user-images.githubusercontent.com/54100702/113215447-7d4fd400-9298-11eb-9b5d-49f99c258ed3.png)

**These are also bypassed in GitHub actions too**
![Screenshot from 2021-04-01 03-19-21](https://user-images.githubusercontent.com/54100702/113216009-59d95900-9299-11eb-8f00-b5c4dafe1a8c.png)

Lint checks should catch 'xdescribe' and 'xit'
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**
Currently, lint checks looks only for `fdescriibe` and `fit`.
It should also catch and throw an error message in case of `xdescribe` and `xit`.
This is critical because I've managed to **bypass pre-commit lint checks** using this method.
This will cause unnecessary difficulties in the development life cycle.
**To Reproduce**
Steps to reproduce the behavior:
 1. Go to any one of the .spec files
 2. use `xdescribe` or `xit`

**Observed behavior**
Pre-commit lint checks failing to catch `xdescribe` and `xit`

**Expected behavior**
Pre-commit lint checks should catch `xdescribe` and `xit`

**Screenshots**
![Screenshot from 2021-04-01 03-08-28](https://user-images.githubusercontent.com/54100702/113215447-7d4fd400-9298-11eb-9b5d-49f99c258ed3.png)

**These are also bypassed in GitHub actions too**
![Screenshot from 2021-04-01 03-19-21](https://user-images.githubusercontent.com/54100702/113216009-59d95900-9299-11eb-8f00-b5c4dafe1a8c.png)



Discussion:
PTAL @U8NWXD @seanlip 
Thanks! Seems reasonable to me to fix this, though I defer to @U8NWXD for the decision.
I think this makes sense to implement. @Hudda @DubeySandeep can we add this to #8423?
@Radesh-kumar, Thanks for reporting, we will soon add a check for this!

@AdityaDubey0, as discussed before on this, can you please create a PR to add a check (in eslint)? (I've assigned you to this issue) 
PTAL @DubeySandeep @AdityaDubey0 I've already opened a PR
@Radesh-kumar are you planning to write the checks in eslint?
PTAL @U8NWXD @seanlip 
Thanks! Seems reasonable to me to fix this, though I defer to @U8NWXD for the decision.
I think this makes sense to implement. @Hudda @DubeySandeep can we add this to #8423?
@Radesh-kumar, Thanks for reporting, we will soon add a check for this!

@AdityaDubey0, as discussed before on this, can you please create a PR to add a check (in eslint)? (I've assigned you to this issue) 
PTAL @DubeySandeep @AdityaDubey0 I've already opened a PR
@Radesh-kumar are you planning to write the checks in eslint?

Resolving patch:
diff --git a/scripts/linters/general_purpose_linter.py b/scripts/linters/general_purpose_linter.py
--- a/scripts/linters/general_purpose_linter.py
+++ b/scripts/linters/general_purpose_linter.py
@@ -141,19 +141,6 @@
             warranted_angular_security_bypasses
             .EXCLUDED_BYPASS_SECURITY_TRUST_DIRECTORIES)
     },
-    {
-        'regexp': re.compile(r'\b(ddescribe|fdescribe)\('),
-        'message': 'In tests, please use \'describe\' instead of \'ddescribe\''
-                   'or \'fdescribe\'',
-        'excluded_files': (),
-        'excluded_dirs': ()
-    },
-    {
-        'regexp': re.compile(r'\b(iit|fit)\('),
-        'message': 'In tests, please use \'it\' instead of \'iit\' or \'fit\'',
-        'excluded_files': (),
-        'excluded_dirs': ()
-    },
     {
         'regexp': re.compile(r'\b(beforeEach\(inject\(function)\('),
         'message': 'In tests, please use \'angular.mock.inject\' instead of '


Test patch:
diff --git a/scripts/linters/general_purpose_linter_test.py b/scripts/linters/general_purpose_linter_test.py
--- a/scripts/linters/general_purpose_linter_test.py
+++ b/scripts/linters/general_purpose_linter_test.py
@@ -56,9 +56,6 @@
 INVALID_PAUSE_FILEPATH = os.path.join(LINTER_TESTS_DIR, 'invalid_pause.js')
 INVALID_WAIT_FOR_ANGULAR_FILEPATH = os.path.join(
     LINTER_TESTS_DIR, 'invalid_wait_for_angular.js')
-INVALID_FDESCRIBE_DDESCRIBE_FILEPATH = os.path.join(
-    LINTER_TESTS_DIR, 'invalid_ddescribe_fdescribe.ts')
-INVALID_IIT_FIT_FILEPATH = os.path.join(LINTER_TESTS_DIR, 'invalid_iit_fit.ts')
 INVALID_INJECT_FILEPATH = os.path.join(LINTER_TESTS_DIR, 'invalid_inject.ts')
 INVALID_INNER_HTML_FILEPATH = os.path.join(
     LINTER_TESTS_DIR, 'invalid_innerhtml.ts')
@@ -196,32 +193,6 @@ def test_invalid_use_of_browser_wait_for_angular(self):
         self.assertEqual('Bad pattern', lint_task_report.name)
         self.assertTrue(lint_task_report.failed)
 
-    def test_invalid_use_of_fdescribe_ddescribe(self):
-        linter = general_purpose_linter.GeneralPurposeLinter(
-            [INVALID_FDESCRIBE_DDESCRIBE_FILEPATH], FILE_CACHE)
-        lint_task_report = linter.check_bad_patterns()
-        self.assert_same_list_elements([
-            'Line 24: In tests, please use \'describe\' instead of '
-            '\'ddescribe\'or \'fdescribe\''], lint_task_report.trimmed_messages)
-        self.assert_same_list_elements([
-            'Line 28: In tests, please use \'describe\' instead of '
-            '\'ddescribe\'or \'fdescribe\''], lint_task_report.trimmed_messages)
-        self.assertEqual('Bad pattern', lint_task_report.name)
-        self.assertTrue(lint_task_report.failed)
-
-    def test_invalid_use_of_iit_fit(self):
-        linter = general_purpose_linter.GeneralPurposeLinter(
-            [INVALID_IIT_FIT_FILEPATH], FILE_CACHE)
-        lint_task_report = linter.check_bad_patterns()
-        self.assert_same_list_elements([
-            'Line 40: In tests, please use \'it\' instead of \'iit\' or '
-            '\'fit\''], lint_task_report.trimmed_messages)
-        self.assert_same_list_elements([
-            'Line 64: In tests, please use \'it\' instead of \'iit\' or '
-            '\'fit\''], lint_task_report.trimmed_messages)
-        self.assertEqual('Bad pattern', lint_task_report.name)
-        self.assertTrue(lint_task_report.failed)
-
     def test_invalid_use_of_inject(self):
         linter = general_purpose_linter.GeneralPurposeLinter(
             [INVALID_INJECT_FILEPATH], FILE_CACHE)
diff --git a/scripts/linters/test_files/invalid_ddescribe_fdescribe.ts b/scripts/linters/test_files/invalid_ddescribe_fdescribe.ts
deleted file mode 100644
--- a/scripts/linters/test_files/invalid_ddescribe_fdescribe.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2020 The Oppia Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Invalid syntax .ts file, used by scripts/linters/
- * js_ts_linter_test.py. This file use ddescribe and fdescribe which is not
- * allowed.
- */
-
-import { CollectionNodeObjectFactory } from
-  'domain/collection/CollectionNodeObjectFactory';
-// ddescribe is not allowed to use.
-ddescribe('Collection node object factory', () => {
-  var collectionNodeObjectFactory: CollectionNodeObjectFactory = null;
-});
-// Use of fdescribe is not allowed.
-fdescribe('Collection node object factory', () => {
-  var collectionNodeObjectFactory: CollectionNodeObjectFactory = null;
-});
diff --git a/scripts/linters/test_files/invalid_iit_fit.ts b/scripts/linters/test_files/invalid_iit_fit.ts
deleted file mode 100644
--- a/scripts/linters/test_files/invalid_iit_fit.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2020 The Oppia Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Invalid syntax .ts file, used by scripts/linters/
- * js_ts_linter_test.py. This file use iit and fit which is not allowed.
- */
-
-import { CollectionNodeObjectFactory } from
-  'domain/collection/CollectionNodeObjectFactory';
-
-describe('Collection node object factory', () => {
-  var collectionNodeObjectFactory: CollectionNodeObjectFactory = null;
-
-  beforeEach(() => {
-    collectionNodeObjectFactory = new CollectionNodeObjectFactory();
-  });
-
-  var _createEmptyCollectionNode = function(explorationId) {
-    return collectionNodeObjectFactory.create({
-      exploration_id: explorationId,
-      exploration_summary: {
-        title: 'Title',
-        status: 'private'
-      }
-    });
-  };
-// iit is not allowed to use.
-  iit('should provide an immutable exploration summary', () => {
-    var explorationSummaryBackendObject = {
-      title: 'exp title',
-      category: 'exp category',
-      objective: 'exp objective'
-    };
-    var collectionNodeBackendObject = {
-      exploration_id: 'exp_id0',
-      exploration_summary: explorationSummaryBackendObject
-    };
-
-    var collectionNode = collectionNodeObjectFactory.create(
-      collectionNodeBackendObject);
-    expect(collectionNode.getExplorationId()).toEqual('exp_id0');
-    expect(collectionNode.getExplorationTitle()).toEqual('exp title');
-
-    var summaryObject = collectionNode.getExplorationSummaryObject();
-    expect(summaryObject).toEqual(explorationSummaryBackendObject);
-
-    delete summaryObject.category;
-    expect(summaryObject).not.toEqual(
-      collectionNode.getExplorationSummaryObject());
-  });
-// fit is not allowed to use.
-  fit('should be able to create a new collection node by exploration ID',
-    () => {
-      var collectionNode = collectionNodeObjectFactory.createFromExplorationId(
-        'exp_id0');
-      expect(collectionNode.getExplorationId()).toEqual('exp_id0');
-      expect(collectionNode.doesExplorationExist()).toBe(false);
-    }
-  );
-});