Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: duplicate eslint rules locally to allow warning #10579

Merged
merged 1 commit into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintplugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ exports.rules = {
'ban-types-eventually': require('@typescript-eslint/eslint-plugin').rules[
'ban-types'
],
'prefer-rest-params-eventually': require('eslint/lib/rules/prefer-rest-params'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these exist off of require('eslint') instead of the deep import?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "do"?

If so then, no they don't - because eslint is the "core", it doesn't export its rules in the same way plugins do, so you can't do require('eslint').rules['<rule>'].

In fact, it doesn't export its rules at all:

❯ node
Welcome to Node.js v14.4.0.
Type ".help" for more information.
> require('eslint')
{
  Linter: [Function: Linter],
  CLIEngine: [Function: CLIEngine] {
    version: '7.8.1',
    getFormatter: [Function: getFormatter]
  },
  ESLint: [Function: ESLint],
  RuleTester: [Function: RuleTester] {
    [Symbol(it)]: null,
    [Symbol(describe)]: null
  },
  SourceCode: [Function: SourceCode]
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

'prefer-spread-eventually': require('eslint/lib/rules/prefer-spread'),
};
35 changes: 34 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,41 @@ module.exports = {
'import/default': 'off',
'no-dupe-class-members': 'off',
'no-unused-vars': 'off',
// TODO: turn these on at some point
},
},
{
files: [
'packages/jest-jasmine2/src/jasmine/Env.ts',
'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts',
'packages/jest-jasmine2/src/jasmine/Spec.ts',
'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/createSpy.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-mock/src/__tests__/index.test.ts',
'packages/jest-mock/src/index.ts',
'packages/pretty-format/src/__tests__/Immutable.test.ts',
'packages/pretty-format/src/__tests__/prettyFormat.test.ts',
],
rules: {
'local/prefer-rest-params-eventually': 'warn',
'prefer-rest-params': 'off',
},
},
{
files: [
'packages/expect/src/index.ts',
'packages/jest-fake-timers/src/legacyFakeTimers.ts',
'packages/jest-jasmine2/src/jasmine/Env.ts',
'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts',
'packages/jest-jasmine2/src/jasmine/Spec.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-jasmine2/src/jestExpect.ts',
'packages/jest-resolve/src/index.ts',
],
rules: {
'local/prefer-spread-eventually': 'warn',
'prefer-spread': 'off',
},
},
Expand Down
2 changes: 2 additions & 0 deletions packages/expect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*
*/

/* eslint-disable local/prefer-spread-eventually */

import * as matcherUtils from 'jest-matcher-utils';
import type {
AsyncExpectationResult,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-fake-timers/src/legacyFakeTimers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable local/ban-types-eventually */
/* eslint-disable local/ban-types-eventually, local/prefer-spread-eventually */

import util = require('util');
import type {ModuleMocker} from 'jest-mock';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmine/Env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys */
/* eslint-disable sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */

import {AssertionError} from 'assert';
import chalk = require('chalk');
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/* eslint-disable local/prefer-spread-eventually, local/prefer-rest-params-eventually */

import type {Reporter, RunDetails} from '../types';
import type {SpecResult} from './Spec';
import type {SuiteResult} from './Suite';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmine/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys */
/* eslint-disable sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */

import {AssertionError} from 'assert';
import type {Config} from '@jest/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmine/SpyStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/* eslint-disable local/ban-types-eventually */
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */

export default class SpyStrategy {
identity: () => string;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmine/Suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/* eslint-disable local/ban-types-eventually, sort-keys */
/* eslint-disable local/ban-types-eventually, sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */

import {convertDescriptorToString} from 'jest-util';
import type {Config} from '@jest/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmine/createSpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys */
/* eslint-disable sort-keys, local/prefer-rest-params-eventually */

import type {Spy} from '../types';
import CallTracker, {Context} from './CallTracker';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmine/jasmineLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys */
/* eslint-disable sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */

import type {Jasmine, SpecDefinitionsFn} from '../types';
import createSpy from './createSpy';
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-jasmine2/src/jestExpect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable local/prefer-spread-eventually */

import expect = require('expect');
import type {Global} from '@jest/types';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-mock/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

/* eslint-disable local/ban-types-eventually */
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */

import vm, {Context} from 'vm';
import {ModuleMocker} from '../';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-mock/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable local/ban-types-eventually */
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */

type Global = NodeJS.Global; // | Window – add once TS improves typings;

Expand Down
2 changes: 2 additions & 0 deletions packages/jest-resolve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable local/prefer-spread-eventually */

import * as path from 'path';
import type {Config} from '@jest/types';
import type {ModuleMap} from 'jest-haste-map';
Expand Down
2 changes: 2 additions & 0 deletions packages/pretty-format/src/__tests__/Immutable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable local/prefer-rest-params-eventually */

import React from 'react';
import Immutable from 'immutable';

Expand Down
2 changes: 2 additions & 0 deletions packages/pretty-format/src/__tests__/prettyFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable local/prefer-rest-params-eventually */

import prettyFormat from '../';

function returnArguments(..._args: Array<unknown>) {
Expand Down