fix: various eslint config issues
This commit is contained in:
parent
ce3d010901
commit
d2adf78dcc
|
@ -42,7 +42,6 @@
|
|||
"ts-jest": "^26.5.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": ">= 4",
|
||||
"eslint": ">=5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import rules from './rules';
|
||||
|
||||
export default {
|
||||
plugins: ['hydrogen'],
|
||||
extends: [
|
||||
'plugin:@shopify/typescript',
|
||||
'plugin:@shopify/react',
|
||||
'plugin:@shopify/node',
|
||||
'plugin:@shopify/prettier',
|
||||
],
|
||||
rules,
|
||||
};
|
|
@ -1,12 +0,0 @@
|
|||
import rules from './rules';
|
||||
|
||||
export default {
|
||||
plugins: ['hydrogen'],
|
||||
extends: [
|
||||
'plugin:@shopify/esnext',
|
||||
'plugin:@shopify/react',
|
||||
'plugin:@shopify/node',
|
||||
'plugin:@shopify/prettier',
|
||||
],
|
||||
rules,
|
||||
};
|
|
@ -1,4 +0,0 @@
|
|||
export default {
|
||||
'hydrogen/no-state-in-server-components': 'error',
|
||||
'hydrogen/prefer-image-component': 'error',
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
import {deepMerge} from '@typescript-eslint/experimental-utils/dist/eslint-utils';
|
||||
import overrides from './overrides';
|
||||
import hydrogen from './hydrogen';
|
||||
|
||||
export default deepMerge(hydrogen, overrides);
|
|
@ -1,45 +0,0 @@
|
|||
export default {
|
||||
// TODO: We may want to change the configuration for the following 3 rules
|
||||
'jsx-a11y/click-events-have-key-events': 'off',
|
||||
'jsx-a11y/no-noninteractive-element-interactions': 'off',
|
||||
'react/jsx-filename-extension': ['error', {extensions: ['.tsx', '.jsx']}],
|
||||
|
||||
/**
|
||||
* Rules below this line are intentionally disabled for different reasons
|
||||
*/
|
||||
|
||||
// The following 2 rules are very strict and disabled here to lessen developer frustration
|
||||
'@shopify/jsx-no-hardcoded-content': 'off',
|
||||
'@shopify/jsx-no-complex-expressions': 'off',
|
||||
|
||||
/**
|
||||
* eslint overrides
|
||||
*/
|
||||
|
||||
// We often define GraphQL queries at the bottom of the file which would be a violation for this rule
|
||||
'no-use-before-define': 'off',
|
||||
// We agree that warning comments acceptable
|
||||
'no-warning-comments': 'off',
|
||||
|
||||
/**
|
||||
* react overrides
|
||||
*/
|
||||
|
||||
// Following Next.js and likely this will be the default in most frameworks
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
// We default to typescript for typing, non typescript projects can override this rule if they want
|
||||
'react/prop-types': 'off',
|
||||
|
||||
/**
|
||||
* import overrides
|
||||
*/
|
||||
|
||||
// TODO: We should turn these on, at least partially
|
||||
// 'import/no-unresolved': ['off'],
|
||||
// 'import/extensions': ['off'],
|
||||
|
||||
// These two rules result in a significant number of false positives so we
|
||||
// need to keep them disabled.
|
||||
'jsx-a11y/label-has-for': 'off',
|
||||
'jsx-a11y/control-has-associated-label': 'off',
|
||||
};
|
|
@ -11,6 +11,7 @@ export default {
|
|||
env: {
|
||||
es2021: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
|
@ -21,6 +22,7 @@ export default {
|
|||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'warn',
|
||||
|
@ -39,54 +41,6 @@ export default {
|
|||
},
|
||||
ignorePatterns: ['node_modules/', 'build/', '*.graphql.d.ts', '*.graphql.ts'],
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: ['plugin:@typescript-eslint/recommended'],
|
||||
rules: {
|
||||
'react/prop-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-empty-interface': 'off',
|
||||
'@typescript-eslint/ban-types': [
|
||||
'error',
|
||||
{
|
||||
types: {
|
||||
String: {message: 'Use string instead', fixWith: 'string'},
|
||||
Boolean: {message: 'Use boolean instead', fixWith: 'boolean'},
|
||||
Number: {message: 'Use number instead', fixWith: 'number'},
|
||||
Object: {message: 'Use object instead', fixWith: 'object'},
|
||||
Array: {message: 'Provide a more specific type'},
|
||||
ReadonlyArray: {message: 'Provide a more specific type'},
|
||||
},
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/naming-convention': [
|
||||
'error',
|
||||
{
|
||||
selector: 'default',
|
||||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
trailingUnderscore: 'allowSingleOrDouble',
|
||||
},
|
||||
{
|
||||
selector: 'typeLike',
|
||||
format: ['PascalCase'],
|
||||
},
|
||||
{
|
||||
selector: 'typeParameter',
|
||||
format: ['PascalCase'],
|
||||
leadingUnderscore: 'allow',
|
||||
},
|
||||
{
|
||||
selector: 'interface',
|
||||
format: ['PascalCase'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.test.*'],
|
||||
plugins: ['jest'],
|
||||
|
|
52
packages/eslint-plugin/src/configs/typescript.ts
Normal file
52
packages/eslint-plugin/src/configs/typescript.ts
Normal file
|
@ -0,0 +1,52 @@
|
|||
export default {
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: ['plugin:@typescript-eslint/recommended'],
|
||||
rules: {
|
||||
'react/prop-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-empty-interface': 'off',
|
||||
'@typescript-eslint/ban-types': [
|
||||
'error',
|
||||
{
|
||||
types: {
|
||||
String: {message: 'Use string instead', fixWith: 'string'},
|
||||
Boolean: {message: 'Use boolean instead', fixWith: 'boolean'},
|
||||
Number: {message: 'Use number instead', fixWith: 'number'},
|
||||
Object: {message: 'Use object instead', fixWith: 'object'},
|
||||
Array: {message: 'Provide a more specific type'},
|
||||
ReadonlyArray: {message: 'Provide a more specific type'},
|
||||
},
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/naming-convention': [
|
||||
'error',
|
||||
{
|
||||
selector: 'default',
|
||||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
trailingUnderscore: 'allowSingleOrDouble',
|
||||
},
|
||||
{
|
||||
selector: 'typeLike',
|
||||
format: ['PascalCase'],
|
||||
},
|
||||
{
|
||||
selector: 'typeParameter',
|
||||
format: ['PascalCase'],
|
||||
leadingUnderscore: 'allow',
|
||||
},
|
||||
{
|
||||
selector: 'interface',
|
||||
format: ['PascalCase'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
|
@ -1,9 +1,11 @@
|
|||
import recommended from './configs/recommended';
|
||||
import hydrogen from './configs/hydrogen';
|
||||
import typescript from './configs/typescript';
|
||||
|
||||
export {rules} from './rules';
|
||||
|
||||
export const configs = {
|
||||
recommended,
|
||||
hydrogen,
|
||||
typescript,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue