-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move prettier and eslint config to root of repo (#12497)
## Description We currently have separate prettier and eslint configs in many different directories. This combines all these configs into a single shared config, while preserving the current differences via overrides. Enabling prettier and eslint for additional directories, and standardizing the places where the config is different will be left for a future PR ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
1 parent
03df554
commit 98a37d4
Showing
47 changed files
with
1,146 additions
and
1,170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,304 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module.exports = { | ||
plugins: ['@tanstack/query', 'unused-imports', 'prettier', 'header'], | ||
extends: [ | ||
'eslint:recommended', | ||
'react-app', | ||
'plugin:@tanstack/eslint-plugin-query/recommended', | ||
'prettier', | ||
'plugin:prettier/recommended', | ||
], | ||
settings: { | ||
react: { | ||
version: '18', | ||
}, | ||
}, | ||
root: true, | ||
ignorePatterns: ['node_modules', 'build', 'dist', 'coverage'], | ||
rules: { | ||
'no-case-declarations': 'off', | ||
'no-implicit-coercion': [ | ||
2, | ||
{ number: true, string: true, boolean: false }, | ||
], | ||
'@typescript-eslint/no-redeclare': 'off', | ||
'@typescript-eslint/ban-types': [ | ||
'error', | ||
{ | ||
types: { | ||
Buffer: 'Buffer usage increases bundle size and is not consistently implemented on web.', | ||
}, | ||
extendDefaults: true, | ||
}, | ||
], | ||
'no-restricted-globals': [ | ||
'error', | ||
{ | ||
name: 'Buffer', | ||
message: | ||
'Buffer usage increases bundle size and is not consistently implemented on web.', | ||
}, | ||
], | ||
'header/header': [ | ||
2, | ||
'line', | ||
[ | ||
' Copyright (c) Mysten Labs, Inc.', | ||
' SPDX-License-Identifier: Apache-2.0', | ||
], | ||
], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['apps/explorer/**/*'], | ||
rules: { | ||
'import/order': [ | ||
'warn', | ||
{ | ||
groups: [ | ||
['builtin', 'external'], | ||
['internal', 'parent', 'sibling', 'index'], | ||
'type', | ||
], | ||
pathGroups: [ | ||
{ | ||
pattern: '{.,..}/**/*.css', | ||
group: 'type', | ||
position: 'after', | ||
}, | ||
], | ||
'newlines-between': 'always', | ||
alphabetize: { order: 'asc' }, | ||
warnOnUnassignedImports: true, | ||
}, | ||
], | ||
'import/no-duplicates': ['error'], | ||
'import/no-anonymous-default-export': 'off', | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ | ||
prefer: 'type-imports', | ||
disallowTypeAnnotations: true, | ||
fixStyle: 'inline-type-imports', | ||
}, | ||
], | ||
'@typescript-eslint/unified-signatures': 'error', | ||
'@typescript-eslint/parameter-properties': 'error', | ||
'react/jsx-key': ['error', {}], | ||
|
||
'react/boolean-prop-naming': 'off', | ||
'react/jsx-boolean-value': ['error', 'never'], | ||
|
||
// Always use function declarations for components | ||
'react/function-component-definition': [ | ||
'error', | ||
{ | ||
namedComponents: 'function-declaration', | ||
unnamedComponents: 'arrow-function', | ||
}, | ||
], | ||
'react/prefer-stateless-function': 'error', | ||
'react/jsx-pascal-case': [ | ||
'error', | ||
{ allowAllCaps: true, allowNamespace: true }, | ||
], | ||
|
||
// Always self-close when applicable | ||
'react/self-closing-comp': [ | ||
'error', | ||
{ | ||
component: true, | ||
html: true, | ||
}, | ||
], | ||
'react/void-dom-elements-no-children': 'error', | ||
|
||
// Use alternatives instead of danger | ||
'react/no-danger': 'error', | ||
'react/no-danger-with-children': 'error', | ||
|
||
// Accessibility requirements | ||
'react/button-has-type': 'error', | ||
'react/no-invalid-html-attribute': 'error', | ||
|
||
// Security requirements | ||
'react/jsx-no-script-url': 'error', | ||
'react/jsx-no-target-blank': 'error', | ||
|
||
// Enforce consistent JSX spacing and syntax | ||
'react/jsx-no-comment-textnodes': 'error', | ||
'react/jsx-no-duplicate-props': 'error', | ||
'react/jsx-no-undef': 'error', | ||
'react/jsx-space-before-closing': 'off', | ||
|
||
// Avoid interpolation as much as possible | ||
'react/jsx-curly-brace-presence': [ | ||
'error', | ||
{ props: 'never', children: 'never' }, | ||
], | ||
|
||
// Always use shorthand fragments when applicable | ||
'react/jsx-fragments': ['error', 'syntax'], | ||
'react/jsx-no-useless-fragment': [ | ||
'error', | ||
{ allowExpressions: true }, | ||
], | ||
'react/jsx-handler-names': [ | ||
'error', | ||
{ | ||
eventHandlerPropPrefix: 'on', | ||
}, | ||
], | ||
|
||
// Avoid bad or problematic patterns | ||
'react/jsx-uses-vars': 'error', | ||
'react/no-access-state-in-setstate': 'error', | ||
'react/no-arrow-function-lifecycle': 'error', | ||
'react/no-children-prop': 'error', | ||
'react/no-did-mount-set-state': 'error', | ||
'react/no-did-update-set-state': 'error', | ||
'react/no-direct-mutation-state': 'error', | ||
'react/no-namespace': 'error', | ||
'react/no-redundant-should-component-update': 'error', | ||
'react/no-render-return-value': 'error', | ||
'react/no-string-refs': 'error', | ||
'react/no-this-in-sfc': 'error', | ||
'react/no-typos': 'error', | ||
'react/no-unescaped-entities': 'error', | ||
'react/no-unknown-property': 'error', | ||
'react/no-unused-class-component-methods': 'error', | ||
'react/no-will-update-set-state': 'error', | ||
'react/require-optimization': 'off', | ||
'react/style-prop-object': 'error', | ||
'react/no-unstable-nested-components': 'error', | ||
|
||
// We may eventually want to turn this on but it requires migration: | ||
'react/no-array-index-key': 'off', | ||
|
||
// Require usage of the custom Link component: | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
paths: [ | ||
{ | ||
name: 'react-router-dom', | ||
importNames: [ | ||
'Link', | ||
'useNavigate', | ||
'useSearchParams', | ||
], | ||
message: | ||
'Please use `LinkWithQuery`, `useSearchParamsMerged`, and `useNavigateWithQuery` from "~/ui/utils/LinkWithQuery" instead.', | ||
}, | ||
], | ||
}, | ||
], | ||
'arrow-body-style': ['error', 'as-needed'], | ||
}, | ||
}, | ||
{ | ||
files: ['apps/wallet/**/*'], | ||
rules: { | ||
'react/display-name': 'off', | ||
'import/order': [ | ||
'warn', | ||
{ | ||
groups: [ | ||
['builtin', 'external'], | ||
['internal', 'parent', 'sibling', 'index'], | ||
'type', | ||
], | ||
pathGroups: [ | ||
{ | ||
pattern: '{.,..,_*,*}/**/*.?(s)css', | ||
group: 'type', | ||
position: 'after', | ||
}, | ||
{ | ||
pattern: '_*', | ||
group: 'internal', | ||
}, | ||
{ | ||
pattern: '_*/**', | ||
group: 'internal', | ||
}, | ||
], | ||
pathGroupsExcludedImportTypes: [ | ||
'builtin', | ||
'object', | ||
'type', | ||
], | ||
'newlines-between': 'always', | ||
alphabetize: { order: 'asc' }, | ||
warnOnUnassignedImports: true, | ||
}, | ||
], | ||
'import/no-duplicates': ['error'], | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ | ||
prefer: 'type-imports', | ||
disallowTypeAnnotations: true, | ||
fixStyle: 'inline-type-imports', | ||
}, | ||
], | ||
'@typescript-eslint/unified-signatures': 'error', | ||
'@typescript-eslint/parameter-properties': 'error', | ||
'no-console': ['warn'], | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
}, | ||
}, | ||
{ | ||
files: [ | ||
'apps/wallet/src/**/*.test.*', | ||
'apps/wallet/src/**/*.spec.*', | ||
], | ||
|
||
rules: { | ||
// Allow any casting in tests: | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['dapps/kiosk/**/*'], | ||
rules: { | ||
'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off", | ||
'unused-imports/no-unused-imports': 'error', | ||
'unused-imports/no-unused-vars': [ | ||
'warn', | ||
{ | ||
vars: 'all', | ||
varsIgnorePattern: '^_', | ||
args: 'after-used', | ||
argsIgnorePattern: '^_', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
files: ['sdk/ledgerjs-hw-app-sui/**/*', 'apps/wallet/**/*'], | ||
rules: { | ||
// ledgerjs-hw-app-sui and wallet use Buffer | ||
'no-restricted-globals': ['off'], | ||
'@typescript-eslint/ban-types': ['off'], | ||
}, | ||
}, | ||
{ | ||
files: ['*.test.*', '*.spec.*'], | ||
rules: { | ||
// Reset to defaults to allow `Buffer` usage in tests (given they run in Node and do not impact bundle): | ||
'no-restricted-globals': ['off'], | ||
'@typescript-eslint/ban-types': ['error'], | ||
}, | ||
}, | ||
{ | ||
files: ['*.stories.*'], | ||
rules: { | ||
// Story files have render functions that this rule incorrectly warns on: | ||
'react-hooks/rules-of-hooks': 'off', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
strict-peer-dependencies=false | ||
auto-install-peers=false | ||
public-hoist-pattern[]=*storybook* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ignore everything by default | ||
/* | ||
# Enable prettier for apps, dapps and sdk | ||
!/apps | ||
!/sdk | ||
!/dapps | ||
!/.config | ||
!/*.js | ||
|
||
# Ignroe generated icons | ||
/apps/icons/src | ||
|
||
# Ignore packages that didn't use prettier yet (will be enabled in a future PR) | ||
/sdk/bcs | ||
/sdk/wallet-adapter | ||
/dapps/offline-signer-helper | ||
/dapps/sponsored-transactions | ||
|
||
# ignore generated files | ||
npm-debug.log* | ||
package-lock.json | ||
yarn-debug.log* | ||
.next/ | ||
.swc/ | ||
build/ | ||
coverage/ | ||
dist/ | ||
out/ | ||
playwright-report/ | ||
storybook-static/ | ||
sdk/wallet-adapter/site/pages/ | ||
CHANGELOG.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"recommendations": [ | ||
"move.move-analyzer", | ||
"rust-lang.rust-analyzer", | ||
"esbenp.prettier-vscode", | ||
"ms-playwright.playwright" | ||
] | ||
"recommendations": [ | ||
"move.move-analyzer", | ||
"rust-lang.rust-analyzer", | ||
"esbenp.prettier-vscode", | ||
"ms-playwright.playwright", | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.