Skip to content

Commit

Permalink
Revert "Consolidate JS and TS configs (#42)"
Browse files Browse the repository at this point in the history
This reverts commit 11726e6.

The functionality that enables this consolidation seems to be
broken. See eslint/eslint#12032
  • Loading branch information
billyjanitsch committed Aug 17, 2019
1 parent f0e6106 commit 77a7e87
Show file tree
Hide file tree
Showing 15 changed files with 192 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
@@ -1 +1 @@
extends: '.'
extends: './javascript.js'
86 changes: 50 additions & 36 deletions __snapshots__/test.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`lints all fixtures: component.js 1`] = `
exports[`lints all JS fixtures: component.js 1`] = `
Array [
Object {
"column": 7,
Expand All @@ -12,11 +12,9 @@ Array [
]
`;

exports[`lints all fixtures: exports.js 1`] = `Array []`;
exports[`lints all JS fixtures: exports.js 1`] = `Array []`;

exports[`lints all fixtures: exports.ts 1`] = `Array []`;

exports[`lints all fixtures: import.js 1`] = `
exports[`lints all JS fixtures: import.js 1`] = `
Array [
Object {
"column": 25,
Expand All @@ -32,22 +30,17 @@ Array [
"rule": "import/no-unresolved",
"severity": 2,
},
]
`;

exports[`lints all fixtures: import.ts 1`] = `
Array [
Object {
"column": 27,
"line": 2,
"message": "Unable to resolve path to module './nonexistent'.",
"rule": "import/no-unresolved",
"column": 19,
"line": 5,
"message": "Useless path segments for \\"../js/exports\\", should be \\"./exports\\"",
"rule": "import/no-useless-path-segments",
"severity": 2,
},
]
`;

exports[`lints all fixtures: prop-types.js 1`] = `
exports[`lints all JS fixtures: prop-types.js 1`] = `
Array [
Object {
"column": 5,
Expand All @@ -73,26 +66,7 @@ Array [
]
`;

exports[`lints all fixtures: prop-types.tsx 1`] = `
Array [
Object {
"column": 16,
"line": 4,
"message": "Missing return type on function.",
"rule": "@typescript-eslint/explicit-function-return-type",
"severity": 2,
},
Object {
"column": 3,
"line": 33,
"message": "defaultProp \\"requiredPropWithDefault\\" defined for isRequired propType.",
"rule": "react/default-props-match-prop-types",
"severity": 2,
},
]
`;

exports[`lints all fixtures: variables.js 1`] = `
exports[`lints all JS fixtures: variables.js 1`] = `
Array [
Object {
"column": 24,
Expand Down Expand Up @@ -125,7 +99,47 @@ Array [
]
`;

exports[`lints all fixtures: variables.ts 1`] = `
exports[`lints all TS fixtures: exports.ts 1`] = `Array []`;

exports[`lints all TS fixtures: import.ts 1`] = `
Array [
Object {
"column": 27,
"line": 2,
"message": "Unable to resolve path to module './nonexistent'.",
"rule": "import/no-unresolved",
"severity": 2,
},
Object {
"column": 19,
"line": 5,
"message": "Useless path segments for \\"../ts/exports\\", should be \\"./exports\\"",
"rule": "import/no-useless-path-segments",
"severity": 2,
},
]
`;

exports[`lints all TS fixtures: prop-types.tsx 1`] = `
Array [
Object {
"column": 16,
"line": 4,
"message": "Missing return type on function.",
"rule": "@typescript-eslint/explicit-function-return-type",
"severity": 2,
},
Object {
"column": 3,
"line": 33,
"message": "defaultProp \\"requiredPropWithDefault\\" defined for isRequired propType.",
"rule": "react/default-props-match-prop-types",
"severity": 2,
},
]
`;

exports[`lints all TS fixtures: variables.ts 1`] = `
Array [
Object {
"column": 24,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fixtures/import.js → fixtures/js/import.js
Expand Up @@ -2,4 +2,4 @@ import something, {foo, baz} from './exports' // baz is not exported
import somethingElse from './nonexistent' // file does not exist

export {foo, baz, something, somethingElse}
export {bar} from './exports'
export {bar} from '../js/exports'
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fixtures/import.ts → fixtures/ts/import.ts
Expand Up @@ -2,4 +2,4 @@ import something, {foo, baz} from './exports' // baz is not exported
import somethingElse from './nonexistent' // file does not exist

export {foo, baz, something, somethingElse}
export {bar} from './exports'
export {bar} from '../ts/exports'
File renamed without changes.
File renamed without changes.
149 changes: 22 additions & 127 deletions index.js
@@ -1,133 +1,28 @@
module.exports = {
extends: ['airbnb', 'airbnb/hooks', 'prettier', 'prettier/react'],
plugins: ['prettier'],
parser: 'babel-eslint',
env: {
// allow browser globals
browser: true,
},
extends: [
require.resolve('./javascript'),
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'prettier/@typescript-eslint',
],
rules: {
// https://github.com/prettier/eslint-config-prettier#arrow-body-style-and-prefer-arrow-callback
'arrow-body-style': [2, 'as-needed', {requireReturnForObjectLiteral: false}],

// ensure that default, named, and namespaced imports have been exported by the target file
'import/default': 2,
'import/namespace': [2, {allowComputed: true}],

// require import groups to be ordered by specificity and separated by linebreaks
'import/order': [2, {'newlines-between': 'always'}],

// allow non-ID-linked <label>s to accomodate those containing linked <input>s
'jsx-a11y/label-has-for': 0,
'jsx-a11y/label-has-associated-control': [2, {assert: 'either'}],

// allow event listeners on static elements (e.g. onClick on divs)
'jsx-a11y/no-static-element-interactions': 0,

// https://github.com/prettier/eslint-config-prettier#arrow-body-style-and-prefer-arrow-callback
'prefer-arrow-callback': [2, {allowNamedFunctions: false, allowUnboundThis: true}],

'prettier/prettier': [
// upgrade severity from warning to error
'@typescript-eslint/explicit-function-return-type': [
2,
{
printWidth: 100,
semi: false,
singleQuote: true,
trailingComma: 'es5',
bracketSpacing: false,
},
{allowExpressions: true, allowTypedFunctionExpressions: true},
],

// disallow .jsx files for consistency
'react/jsx-filename-extension': 0,

// allow function creation in render
'react/jsx-no-bind': 0,

// do not require default props for optional props
'react/require-default-props': 0,

'react/sort-comp': [
2,
{
order: [
'lifecycle-statics',
'static-methods',
'constructor',
'instance-variables',
'lifecycle-methods',
'everything-else',
'render',
],
groups: {
'lifecycle-statics': [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'defaultProps',
],
'lifecycle-methods': [
'state',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount',
],
},
},
],

// permit both styles of state declaration
'react/state-in-constructor': 0,

// require statics to be declared as public fields
'react/static-property-placement': [2, 'static public field'],
},
settings: {
// do not attempt to parse npm modules or non-JS files for exports
'import/ignore': ['node_modules', '.(png|svg|jpg|css|pdf)$'],
'import/extensions': ['.js'],
react: {version: '16.8.1'},
'@typescript-eslint/no-explicit-any': 2,

// these are checked by the TS compiler
'@typescript-eslint/no-unused-vars': 0,
'import/default': 0,
'import/named': 0,
'import/namespace': 0,
'react/forbid-prop-types': 0,
'react/jsx-no-undef': 0,
'react/no-unused-prop-types': 0,
'react/prop-types': 0,
'react/react-in-jsx-scope': 0,
},
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'prettier/@typescript-eslint',
],
rules: {
// upgrade severity from warning to error
'@typescript-eslint/explicit-function-return-type': [
2,
{allowExpressions: true, allowTypedFunctionExpressions: true},
],
'@typescript-eslint/no-explicit-any': 2,

// these are checked by the TS compiler
'@typescript-eslint/no-unused-vars': 0,
'import/default': 0,
'import/named': 0,
'import/namespace': 0,
'react/forbid-prop-types': 0,
'react/jsx-no-undef': 0,
'react/no-unused-prop-types': 0,
'react/prop-types': 0,
'react/react-in-jsx-scope': 0,
},
},
],
}

0 comments on commit 77a7e87

Please sign in to comment.