Skip to content

Commit

Permalink
Merge pull request #438 from intuit/lint-update
Browse files Browse the repository at this point in the history
disable require-jsdoc on more ArrowExpression cases
  • Loading branch information
hipstersmoothie authored Aug 14, 2020
2 parents 533684c + a6441d3 commit 8b2a1bc
Showing 1 changed file with 42 additions and 39 deletions.
81 changes: 42 additions & 39 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ const path = require('path');
const monorepoRoot = require('@design-systems/cli-utils').getMonorepoRoot();

/** Determine if a filepath exists. */
const exists = filepath => {
const exists = (filepath) => {
if (fs.existsSync(filepath)) {
return filepath;
}
};

const arrowContext =
'*:not(Property):not(CallExpression):not(ArrayExpression):not(ReturnStatement):not(JSXExpressionContainer):not(AssignmentPattern):not(NewExpression):not(ArrowFunctionExpression) > ArrowFunctionExpression';

module.exports = {
env: { jest: true, browser: true },

Expand All @@ -21,24 +24,24 @@ module.exports = {
'xo-react/space',
'plugin:jest/recommended',
'prettier',
'prettier/react'
'prettier/react',
],

plugins: ['prettier', 'jest', 'react-hooks', 'eslint-plugin-jsdoc'],

settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
'eslint-import-resolver-lerna': {
packages: [
exists(path.join(monorepoRoot, 'components')),
exists(path.join(monorepoRoot, 'packages')),
exists(path.join(monorepoRoot, 'plugins'))
].filter(Boolean)
}
}
exists(path.join(monorepoRoot, 'plugins')),
].filter(Boolean),
},
},
},
rules: {
// stylistic
Expand All @@ -64,8 +67,8 @@ module.exports = {
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never'
}
tsx: 'never',
},
],

/* airbnb */
Expand All @@ -87,8 +90,8 @@ module.exports = {
'jsx-a11y/aria-role': [
2,
{
ignoreNonDOM: true
}
ignoreNonDOM: true,
},
],
// Sometimes it makes sense not to
'import/prefer-default-export': 0,
Expand All @@ -111,7 +114,7 @@ module.exports = {
// Only allow JSX in tsx + js files
'react/jsx-filename-extension': [
2,
{ extensions: ['.js', '.jsx', '.tsx'] }
{ extensions: ['.js', '.jsx', '.tsx'] },
],
'react/default-props-match-prop-types': 2,

Expand Down Expand Up @@ -144,28 +147,29 @@ module.exports = {
2,
{
require: {
ArrowFunctionExpression: true,
FunctionDeclaration: true,
ClassDeclaration: true
}
}
]
ClassDeclaration: true,
},
contexts: [arrowContext],
},
],
},
overrides: [
{
files: ['*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
sourceType: 'module'
sourceType: 'module',
},
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint'
'prettier/@typescript-eslint',
],
plugins: ['@typescript-eslint', 'eslint-plugin-no-explicit-type-exports'],
rules: {
'react/prop-types': 0,
'react/default-props-match-prop-types': 0,
'no-explicit-type-exports/no-explicit-type-exports': 2,
'no-unused-expressions': 0,
// !!! Add this back once TS plugins supports `as const`
Expand All @@ -178,26 +182,25 @@ module.exports = {
// just rely on typescript inference
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
'@typescript-eslint/explicit-module-boundary-types': 0,

'jsdoc/require-jsdoc': [
2,
{
contexts: ['TSPropertySignature'],
require: {
ArrowFunctionExpression: true,
FunctionDeclaration: true,
ClassDeclaration: true
}
}
]
}
ClassDeclaration: true,
},
contexts: ['TSPropertySignature', arrowContext],
},
],
},
},
{
files: ['*.{js,jsx}'],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: [
Expand All @@ -207,7 +210,7 @@ module.exports = {
'theme.*',
'*.config.*',
'*.d.ts',
'*.snippet.*'
'*.snippet.*',
],
rules: {
'jsdoc/require-jsdoc': 0,
Expand All @@ -218,23 +221,23 @@ module.exports = {
'jsx-a11y/jsx-a11y/anchor-has-content': 0,
// devDependencies are all in the root
'import/no-extraneous-dependencies': 0,
"@typescript-eslint/ban-ts-comment": 0,
}
'@typescript-eslint/ban-ts-comment': 0,
},
},
{
files: ['*.test.{ts,tsx}', '*.stories.{ts,tsx}'],
rules: {
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/ban-ts-ignore': 0
}
'@typescript-eslint/ban-ts-ignore': 0,
},
},
{
files: ['*.mdx'],
parser: 'eslint-mdx',
plugins: ['mdx'],
globals: {
React: true
React: true,
},
rules: {
'import/no-extraneous-dependencies': 0,
Expand All @@ -245,8 +248,8 @@ module.exports = {
// jsx is allowed in mdx
'react/jsx-filename-extension': 0,
// No exported function in MDX
"jsdoc/require-jsdoc": 0
}
}
].filter(Boolean)
'jsdoc/require-jsdoc': 0,
},
},
].filter(Boolean),
};

0 comments on commit 8b2a1bc

Please sign in to comment.