eslint-config-xo-typescript
Advanced tools
Comparing version 0.48.0 to 0.49.0
154
index.js
'use strict'; | ||
const getNamingConventionRule = ({isTsx}) => ({ | ||
"@typescript-eslint/naming-convention": [ | ||
'error', | ||
{ | ||
// selector: ['variableLike', 'memberLike', 'property', 'method'], | ||
// Note: Leaving out `parameter` and `typeProperty` because of the mentioned known issues. | ||
// Note: We are intentionally leaving out `enumMember` as it's usually pascal-case or upper-snake-case. | ||
selector: ['variable', 'function', 'classProperty', 'objectLiteralProperty', 'parameterProperty', 'classMethod', 'objectLiteralMethod', 'typeMethod', 'accessor'], | ||
format: [ | ||
'strictCamelCase', | ||
isTsx && 'StrictPascalCase', | ||
].filter(Boolean), | ||
// We allow double underscore because of GraphQL type names and some React names. | ||
leadingUnderscore: 'allowSingleOrDouble', | ||
trailingUnderscore: 'allow', | ||
// Ignore `{'Retry-After': retryAfter}` type properties. | ||
filter: { | ||
regex: '[- ]', | ||
match: false | ||
} | ||
}, | ||
{ | ||
selector: 'typeLike', | ||
format: [ | ||
'StrictPascalCase' | ||
] | ||
}, | ||
{ | ||
selector: 'variable', | ||
types: [ | ||
'boolean' | ||
], | ||
format: [ | ||
'StrictPascalCase' | ||
], | ||
prefix: [ | ||
'is', | ||
'has', | ||
'can', | ||
'should', | ||
'will', | ||
'did' | ||
] | ||
}, | ||
{ | ||
// Interface name should not be prefixed with `I`. | ||
selector: 'interface', | ||
filter: /^(?!I)[A-Z]/.source, | ||
format: [ | ||
'StrictPascalCase' | ||
] | ||
}, | ||
{ | ||
// Type parameter name should either be `T` or a descriptive name. | ||
selector: 'typeParameter', | ||
filter: /^T$|^[A-Z][a-zA-Z]+$/.source, | ||
format: [ | ||
'StrictPascalCase' | ||
] | ||
}, | ||
// Allow these in non-camel-case when quoted. | ||
{ | ||
selector: [ | ||
'classProperty', | ||
'objectLiteralProperty' | ||
], | ||
format: null, | ||
modifiers: [ | ||
'requiresQuotes' | ||
] | ||
} | ||
] | ||
}); | ||
module.exports = { | ||
@@ -277,72 +352,3 @@ parser: require.resolve('@typescript-eslint/parser'), | ||
// TODO: Prevent `_` prefix on private fields when TypeScript 3.8 is out. | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
// selector: ['variableLike', 'memberLike', 'property', 'method'], | ||
// Note: Leaving out `parameter` and `typeProperty` because of the mentioned known issues. | ||
// Note: We are intentionally leaving out `enumMember` as it's usually pascal-case or upper-snake-case. | ||
selector: ['variable', 'function', 'classProperty', 'objectLiteralProperty', 'parameterProperty', 'classMethod', 'objectLiteralMethod', 'typeMethod', 'accessor'], | ||
format: [ | ||
'strictCamelCase' | ||
], | ||
// We allow double underscope because of GraphQL type names and some React names. | ||
leadingUnderscore: 'allowSingleOrDouble', | ||
trailingUnderscore: 'allow', | ||
// Ignore `{'Retry-After': retryAfter}` type properties. | ||
filter: { | ||
regex: '[- ]', | ||
match: false | ||
} | ||
}, | ||
{ | ||
selector: 'typeLike', | ||
format: [ | ||
'StrictPascalCase' | ||
] | ||
}, | ||
{ | ||
selector: 'variable', | ||
types: [ | ||
'boolean' | ||
], | ||
format: [ | ||
'StrictPascalCase' | ||
], | ||
prefix: [ | ||
'is', | ||
'has', | ||
'can', | ||
'should', | ||
'will', | ||
'did' | ||
] | ||
}, | ||
{ | ||
// Interface name should not be prefixed with `I`. | ||
selector: 'interface', | ||
filter: /^(?!I)[A-Z]/.source, | ||
format: [ | ||
'StrictPascalCase' | ||
] | ||
}, | ||
{ | ||
// Type parameter name should either be `T` or a descriptive name. | ||
selector: 'typeParameter', | ||
filter: /^T$|^[A-Z][a-zA-Z]+$/.source, | ||
format: [ | ||
'StrictPascalCase' | ||
] | ||
}, | ||
// Allow these in non-camel-case when quoted. | ||
{ | ||
selector: [ | ||
'classProperty', | ||
'objectLiteralProperty' | ||
], | ||
format: null, | ||
modifiers: [ | ||
'requiresQuotes' | ||
] | ||
} | ||
], | ||
...getNamingConventionRule({isTsx: false}), | ||
'@typescript-eslint/no-base-to-string': 'error', | ||
@@ -678,4 +684,12 @@ 'no-array-constructor': 'off', | ||
} | ||
}, | ||
{ | ||
files: [ | ||
'**/*.tsx' | ||
], | ||
rules: { | ||
...getNamingConventionRule({isTsx: true}) | ||
} | ||
} | ||
] | ||
}; |
{ | ||
"name": "eslint-config-xo-typescript", | ||
"version": "0.48.0", | ||
"version": "0.49.0", | ||
"description": "ESLint shareable config for TypeScript to be used with eslint-config-xo", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24430
659