Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from vend/update-v6
Browse files Browse the repository at this point in the history
Update in preparation for v6
  • Loading branch information
edsrzf authored Jan 15, 2021
2 parents 14034ef + a98098d commit b2a0444
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 403 deletions.
129 changes: 63 additions & 66 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'jsx-a11y', 'prettier', 'react-hooks'],
settings: {
react: {
version: 'detect',
version: 'latest',
},
},
extends: [
Expand Down Expand Up @@ -43,8 +43,8 @@ module.exports = {
// Don't allow unused labels.
'no-unused-labels': 'off',

// Disallow the 'var' keyword.
'no-var': 'error',
// Disabled because it's more annoying than useful with TypeScript.
'no-use-before-define': 'off',

// Prefer ES6 shorthand notation in object literals.
'object-shorthand': 'error',
Expand All @@ -55,59 +55,6 @@ module.exports = {
// Require the radix argument to parseInt to avoid unintentionally allowing hex or octal.
radix: 'error',

// Naming conventions. The TypeScript rule is much more complete and configurable than ESLint's.
camelcase: 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'variable',
// Allow PascalCase for React components, UPPER_CASE for constants.
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'function',
// Allow PascalCase for React components.
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
// Don't require object properties to conform to any convention.
{
selector: 'property',
format: null,
},
// However, require class members to be camelCase.
{
selector: 'memberLike',
modifiers: ['private', 'protected', 'public'],
format: ['camelCase'],
},
// Types should be PascalCase.
{
selector: 'typeLike',
format: ['PascalCase'],
},
// But sometimes we use enums like consts, especially when converting from JS.
{
selector: 'enum',
format: ['PascalCase', 'UPPER_CASE'],
},
{
selector: 'enumMember',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
],

// Require imports to be first in the file, as they're hoisted.
'import/first': 'error',

Expand Down Expand Up @@ -156,6 +103,7 @@ module.exports = {
'react/jsx-handler-names': 'off',

// We use TypeScript so don't usually need PropTypes.
'react/no-unused-prop-types': 'off',
'react/prop-types': 'off',

// Prevent stale closures in useEffect, useCallback, etc.
Expand Down Expand Up @@ -204,6 +152,65 @@ module.exports = {
},

rules: {
// Naming conventions. The TypeScript rule is much more complete and configurable than ESLint's.
camelcase: 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'variable',
// Allow PascalCase for React components, UPPER_CASE for constants.
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'function',
// Allow PascalCase for React components.
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
// Don't require destructured names to conform to any convention.
{
selector: 'default',
modifiers: ['destructured'],
format: null,
},
// Don't require object properties to conform to any convention.
{
selector: 'property',
format: null,
},
// However, require class members to be camelCase.
{
selector: 'memberLike',
modifiers: ['private', 'protected', 'public'],
format: ['camelCase'],
},
// Types should be PascalCase.
{
selector: 'typeLike',
format: ['PascalCase'],
},
// But sometimes we use enums like consts, especially when converting from JS.
{
selector: 'enum',
format: ['PascalCase', 'UPPER_CASE'],
},
{
selector: 'enumMember',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
],

// Checked by TypeScript and creates false positives with class method
// overloads.
'no-dupe-class-members': 'off',
Expand Down Expand Up @@ -276,12 +283,6 @@ module.exports = {
{ assertionStyle: 'as' },
],

// Prefer interfaces over type literals (type T = { ... }).
'@typescript-eslint/consistent-type-definitions': [
'error',
'interface',
],

// Require fields and methods to be explicitly labeled public, private, or protected.
// Exclude public constructors.
'@typescript-eslint/explicit-member-accessibility': [
Expand Down Expand Up @@ -311,10 +312,6 @@ module.exports = {
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',

// Don't allow extra semi-colons.
'no-extra-semi': 'off',
'@typescript-eslint/no-extra-semi': 'error',

// Disallow empty interfaces, which are not useful.
'@typescript-eslint/no-empty-interface': 'error',

Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@
"repository": "https://github.com/vend/eslint-config",
"license": "MIT",
"scripts": {
"lint": "eslint . --config=index.js"
"lint": "eslint . --config=index.js",
"test": "yarn lint"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^3.3.0",
"eslint": ">=7.0.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react-hooks": "^4.0.4"
"@typescript-eslint/eslint-plugin": "^4.12.0",
"eslint": "^7.17.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react-hooks": "^4.2.0"
},
"dependencies": {
"confusing-browser-globals": "^1.0.9",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",
"eslint-config-standard-react": "^9.2.0"
"confusing-browser-globals": "^1.0.10",
"eslint-config-prettier": "^7.1.0",
"eslint-config-standard": "^16.0.2",
"eslint-config-standard-react": "^11.0.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",
"eslint": "^7.3.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.3.1",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"eslint": "^7.17.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-standard": "^4.0.1",
"prettier": "^2.0.5",
"typescript": "^3.9.5"
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
}
}
Loading

0 comments on commit b2a0444

Please sign in to comment.