Skip to content

Commit

Permalink
chore: use own eslint rules, not from fb config
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Nov 26, 2020
1 parent 608aa79 commit f270356
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 318 deletions.
234 changes: 204 additions & 30 deletions .eslintrc.js
Expand Up @@ -17,17 +17,22 @@ const internalPackages = getPackages()
.sort();

module.exports = {
env: {
'jest/globals': true,
node: true,
},
extends: [
'fb-strict',
'plugin:import/errors',
'plugin:import/typescript',
'prettier',
'prettier/flowtype',
'plugin:eslint-comments/recommended',
],
overrides: [
{
extends: ['plugin:@typescript-eslint/eslint-recommended'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/typescript',
'prettier/@typescript-eslint',
],
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
rules: {
Expand Down Expand Up @@ -139,34 +144,22 @@ module.exports = {
rules: {
'arrow-body-style': 'off',
'consistent-return': 'off',
'flowtype/require-valid-file-annotation': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
'jest/valid-expect': 'off',
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'off',
'react/jsx-no-undef': 'off',
'react/react-in-jsx-scope': 'off',
'sort-keys': 'off',
},
},
{
files: ['examples/**/*'],
rules: {
'babel/func-params-comma-dangle': 'off',
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
'import/order': 'off',
},
},
{
files: ['scripts/**/*', 'e2e/**/*'],
rules: {
'babel/func-params-comma-dangle': 'off',
},
},
{
files: 'packages/jest-types/**/*',
rules: {
Expand Down Expand Up @@ -225,23 +218,68 @@ module.exports = {
},
},
{
files: ['test-types/*.test.ts'],
files: ['test-types/*.test.ts', '*.md'],
rules: {
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
'jest/valid-expect': 'off',
},
},
{
files: [
'scripts/*',
'packages/jest-cli/src/init/index.ts',
'packages/jest-repl/src/cli/runtime-cli.ts',
],
rules: {
'no-console': 'off',
},
},
{
files: [
'e2e/**',
'examples/**',
'scripts/*',
'website/**',
'**/__mocks__/**',
'**/__tests__/**',
'**/__performance_tests__/**',
'packages/diff-sequences/perf/index.js',
'packages/pretty-format/perf/test.js'
],
rules: {
'import/no-unresolved': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
},
},
],
parser: '@typescript-eslint/parser',
plugins: ['markdown', 'import', 'prettier', 'eslint-comments'],
parserOptions: {
sourceType: 'module',
},
plugins: ['markdown', 'import', 'jest'],
rules: {
'arrow-body-style': 'error',
'accessor-pairs': ['warn', {setWithoutGet: true}],
'block-scoped-var': 'off',
'callback-return': 'off',
camelcase: ['off', {properties: 'always'}],
complexity: 'off',
'consistent-return': 'warn',
'consistent-this': ['off', 'self'],
'constructor-super': 'error',
'default-case': 'off',
'dot-notation': 'off',
eqeqeq: ['off', 'allow-null'],
'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
'eslint-comments/no-unused-disable': 'error',
'flowtype/boolean-style': 'error',
'flowtype/no-primitive-constructor-types': 'error',
'flowtype/require-valid-file-annotation': 'error',
'func-names': 'off',
'func-style': ['off', 'declaration'],
'global-require': 'off',
'guard-for-in': 'off',
'handle-callback-err': 'off',
'id-length': 'off',
'id-match': 'off',
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
'error',
Expand Down Expand Up @@ -277,17 +315,153 @@ module.exports = {
'newlines-between': 'never',
},
],
'no-console': 'off',
'init-declarations': 'off',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error',
'lines-around-comment': 'off',
'max-depth': 'off',
'max-nested-callbacks': 'off',
'max-params': 'off',
'max-statements': 'off',
'new-cap': 'off',
'new-parens': 'error',
'newline-after-var': 'off',
'no-alert': 'off',
'no-array-constructor': 'error',
'no-bitwise': 'warn',
'no-caller': 'error',
'no-case-declarations': 'off',
'no-catch-shadow': 'error',
'no-class-assign': 'warn',
'no-cond-assign': 'off',
'no-confusing-arrow': 'off',
'no-console': [
'warn',
{allow: ['warn', 'error', 'time', 'timeEnd', 'timeStamp']},
],
'no-const-assign': 'error',
'no-constant-condition': 'off',
'no-continue': 'off',
'no-control-regex': 'off',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-div-regex': 'off',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'warn',
'no-else-return': 'off',
'no-empty': 'off',
'no-empty-character-class': 'warn',
'no-empty-pattern': 'warn',
'no-eq-null': 'off',
'no-eval': 'error',
'no-ex-assign': 'warn',
'no-extend-native': 'warn',
'no-extra-bind': 'warn',
'no-extra-boolean-cast': 'warn',
'no-fallthrough': 'warn',
'no-floating-decimal': 'error',
'no-func-assign': 'error',
'no-implicit-coercion': 'off',
'no-implied-eval': 'error',
'no-inline-comments': 'off',
'no-inner-declarations': 'off',
'no-invalid-regexp': 'warn',
'no-invalid-this': 'off',
'no-irregular-whitespace': 'error',
'no-iterator': 'off',
'no-label-var': 'warn',
'no-labels': ['error', {allowLoop: true, allowSwitch: true}],
'no-lonely-if': 'off',
'no-loop-func': 'off',
'no-magic-numbers': 'off',
'no-mixed-requires': 'off',
'no-mixed-spaces-and-tabs': 'error',
'no-multi-str': 'error',
'no-multiple-empty-lines': 'off',
'no-native-reassign': ['error', {exceptions: ['Map', 'Set']}],
'no-negated-condition': 'off',
'no-negated-in-lhs': 'error',
'no-nested-ternary': 'off',
'no-new': 'warn',
'no-new-func': 'error',
'no-new-object': 'warn',
'no-new-require': 'off',
'no-new-wrappers': 'warn',
'no-obj-calls': 'error',
'no-octal': 'warn',
'no-octal-escape': 'warn',
'no-param-reassign': 'off',
'no-path-concat': 'off',
'no-plusplus': 'off',
'no-process-env': 'off',
'no-process-exit': 'off',
'no-proto': 'error',
'no-redeclare': 'warn',
'no-regex-spaces': 'warn',
'no-restricted-imports': [
'error',
{
message: 'Please use graceful-fs instead.',
name: 'fs',
},
{message: 'Please use graceful-fs instead.', name: 'fs'},
],
'no-restricted-modules': 'off',
'no-restricted-syntax': 'off',
'no-return-assign': 'off',
'no-script-url': 'error',
'no-self-compare': 'warn',
'no-sequences': 'warn',
'no-shadow': 'off',
'no-shadow-restricted-names': 'warn',
'no-sparse-arrays': 'error',
'no-sync': 'off',
'no-ternary': 'off',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-undef': 'error',
'no-undef-init': 'off',
'no-undefined': 'off',
'no-underscore-dangle': 'off',
'no-unneeded-ternary': 'warn',
'no-unreachable': 'error',
'no-unused-expressions': 'off',
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
'no-use-before-define': 'off',
'no-useless-call': 'warn',
'no-useless-computed-key': 'error',
'no-useless-concat': 'warn',
'no-var': 'error',
'no-void': 'off',
'no-warn-comments': 'off',
'no-with': 'off',
'object-shorthand': 'error',
'one-var': ['warn', {initialized: 'never'}],
'operator-assignment': ['warn', 'always'],
'operator-linebreak': 'off',
'padded-blocks': 'off',
'prefer-arrow-callback': ['error', {allowNamedFunctions: true}],
'prefer-const': 'error',
'prefer-template': 'off',
quotes: [
'error',
'single',
{allowTemplateLiterals: true, avoidEscape: true},
],
'no-unused-vars': 'error',
'prettier/prettier': 'error',
radix: 'warn',
'require-jsdoc': 'off',
'require-yield': 'off',
'sort-imports': ['error', {ignoreDeclarationSort: true}],
'sort-keys': 'error',
'sort-vars': 'off',
'spaced-comment': ['off', 'always', {exceptions: ['eslint', 'global']}],
strict: 'off',
'use-isnan': 'error',
'valid-jsdoc': 'off',
'valid-typeof': 'error',
'vars-on-top': 'off',
'wrap-iife': 'off',
'wrap-regex': 'off',
yoda: 'off',
},
settings: {
'import/ignore': ['react-native'],
Expand Down
Expand Up @@ -25,7 +25,7 @@ Object {
"loc": Object {
"end": Object {
"column": 1,
"line": 12,
"line": 11,
},
"start": Object {
"column": 58,
Expand All @@ -45,7 +45,7 @@ Object {
"0": Object {
"end": Object {
"column": 2,
"line": 12,
"line": 11,
},
"start": Object {
"column": 0,
Expand All @@ -55,21 +55,21 @@ Object {
"1": Object {
"end": Object {
"column": 41,
"line": 10,
"line": 9,
},
"start": Object {
"column": 34,
"line": 10,
"line": 9,
},
},
"2": Object {
"end": Object {
"column": 33,
"line": 11,
"line": 10,
},
"start": Object {
"column": 2,
"line": 11,
"line": 10,
},
},
},
Expand Down
Expand Up @@ -5,6 +5,6 @@ exports[`produces code coverage for uncovered files without transformer 1`] = `
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------------|---------|----------|---------|---------|-------------------
All files | 0 | 100 | 0 | 0 |
some-random-file.js | 0 | 100 | 0 | 0 | 8-11
some-random-file.js | 0 | 100 | 0 | 0 | 8-10
---------------------|---------|----------|---------|---------|-------------------
`;
1 change: 0 additions & 1 deletion e2e/coverage-transform-instrumented/covered.js
Expand Up @@ -6,7 +6,6 @@
*/

module.exports = function doES6Stuff(testObj, multiplier) {
// eslint-disable-next-line no-unused-vars
const {someNumber, ...others} = testObj;
return someNumber * multiplier;
};
1 change: 0 additions & 1 deletion e2e/coverage-without-transform/some-random-file.js
Expand Up @@ -6,7 +6,6 @@
*/

module.exports = function doES6Stuff(testObj, multiplier) {
// eslint-disable-next-line no-unused-vars
const {someNumber, ...others} = testObj;
return someNumber * multiplier;
};
4 changes: 1 addition & 3 deletions e2e/native-esm/__tests__/native-esm.test.js
Expand Up @@ -15,13 +15,11 @@ import {jest as jestObject} from '@jest/globals';
import staticImportedStatefulFromCjs from '../fromCjs.mjs';
import {double} from '../index';
import defaultFromCjs, {namedFunction} from '../namedExport.cjs';
// eslint-disable-next-line import/named
import {bag} from '../namespaceExport.js';
import staticImportedStateful from '../stateful.mjs';
// https://github.com/benmosher/eslint-plugin-import/issues/1739
/* eslint-disable import/no-unresolved */
import staticImportedStatefulWithQuery from '../stateful.mjs?query=1';
import staticImportedStatefulWithAnotherQuery from '../stateful.mjs?query=2';
/* eslint-enable */

test('should have correct import.meta', () => {
expect(typeof require).toBe('undefined');
Expand Down
1 change: 1 addition & 0 deletions e2e/reset-modules/__tests__/resetModules.test.js
Expand Up @@ -6,6 +6,7 @@
*/
'use strict';

// eslint-disable-next-line no-undef
global.testObject = new Proxy(
{},
{
Expand Down
1 change: 0 additions & 1 deletion e2e/snapshot-serializers/plugins/bar.js
Expand Up @@ -6,7 +6,6 @@
*
*/

// eslint-disable-next-line no-unused-vars
const createPlugin = require('../utils').createPlugin;

// We inject the call to "createPlugin('bar') through the transformer"

0 comments on commit f270356

Please sign in to comment.