Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prettier (from #59) #76

Draft
wants to merge 15 commits into
base: v2-mst-aptd-gcms-lcz-sty
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 5 additions & 36 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
# See https://blog.theodo.com/2019/08/empower-your-dev-environment-with-eslint-prettier-and-editorconfig-with-no-conflicts/
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
max_line_length = 80 # Gets inherited by .prettierrc
end_of_line = lf # Gets inherited by .prettierrc
indent_style = space # Gets inherited by .prettierrc
indent_size = 2 # Gets inherited by .prettierrc

[{*.jhm, *.xslt, *.xul, *.rng, *.xsl, *.xsd, *.ant, *.tld, *.fxml, *.jrxml, *.xml, *.jnlp, *.wsdl}]
indent_style = space
indent_size = 4

[{.babelrc, .prettierrc, .stylelintrc, .eslintrc, jest.config, *.json, *.js, *.js.map, *.ts, *.tsx, *.jsb3, *.jsb2, *.bowerrc, *.graphqlconfig}]
indent_style = space
indent_size = 2

[.editorconfig]
indent_style = space
indent_size = 4

[*.less]
indent_style = space
indent_size = 2

[*.jshintrc]
indent_style = space
indent_size = 2

[*.jscsrc]
indent_style = space
indent_size = 2

[{tsconfig.lib.json, tsconfig.spec.json, tsconfig.app.json, tsconfig.json, tsconfig.e2e.json}]
indent_style = space
indent_size = 2

[*.ejs]
indent_style = space
indent_size = 4

[{.analysis_options, *.yml, *.yaml}]
indent_style = space
indent_size = 2

[*.md]
indent_size = 4
37 changes: 16 additions & 21 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
---
# XXX Must read to understand how prettier/eslint work together - https://blog.theodo.com/2019/08/empower-your-dev-environment-with-eslint-prettier-and-editorconfig-with-no-conflicts/
# XXX EditorConfig provides everyone with the same editor configuration (prettier inherits from it) - All configuration related to the editor (end of line, indent style, indent size...) should be handled by EditorConfig
# XXX No "code formatting" should be done by ESLint - Everything related to code formatting should be handled by Prettier
# XXX EsLint handles our code quality only - The rest (code quality) should be handled by ESLint
env:
browser: true
commonjs: true
es6: true
node: true
extends:
- plugin:@typescript-eslint/recommended
- plugin:react/recommended
- plugin:jsx-a11y/recommended
globals:
Atomics: readonly
SharedArrayBuffer: readonly
- airbnb-typescript-prettier # https://github.com/toshi-toma/eslint-config-airbnb-typescript-prettier#readme
plugins:
- jest
- react
- react-hooks
parser: '@typescript-eslint/parser'
parserOptions:
project: ./tsconfig.json
globals:
Atomics: readonly
SharedArrayBuffer: readonly
settings:
react:
version: detect
rules: # See https://eslint.org/docs/rules
semi:
- error
- always # Always put commas, to avoid multilines git diff when new lines are added
quotes:
- error
- single # Prefer simple quotes
- allowTemplateLiterals: true # Allow the use of `` instead of '' and don't try to replace it, even when `` isn't needed
# Managed by prettier
# semi
# quotes
# indent
# max-len
comma-spacing:
- error
- before: false
after: true
indent:
- error
- 2
- SwitchCase: 1
arrow-parens:
- error
- always
max-len: 0 # Disable line length checks, because the IDE is already configured to warn about it, and it's a waste of time to check for lines that are too long, especially in comments (like this one!)
strict: 'off'
no-console: 1 # Shouldn't use "console", but "logger" instead
allowArrowFunctions: 0
Expand All @@ -54,6 +46,9 @@ rules: # See https://eslint.org/docs/rules
- consistent-as-needed # Enforce consistency with quotes on props, either all must be quoted, or all unquoted for a given object
no-return-await: 0 # Useful before, but recent node.js enhancements make it useless on node 12+ (we use 10, but still, for consistency) - Read https://stackoverflow.com/questions/44806135/why-no-return-await-vs-const-x-await
no-extra-boolean-cast: 0 # Don't enforce, let developer choose. Using "!!!" is sometimes useful (edge cases), and has a semantic value (dev intention)
array-element-newline: # https://eslint.org/docs/rules/array-element-newline
- error
- consistent
object-curly-newline:
- warn
- ObjectExpression:
Expand Down
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.idea
.next
.now
_site
coverage
cypress/_examples
docs/_site
node_modules
public
src/svg/
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Inherits rules from .editorconfig - See https://blog.theodo.com/2019/08/empower-your-dev-environment-with-eslint-prettier-and-editorconfig-with-no-conflicts/
semi: true
trailingComma: 'all'
singleQuote: true
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
"doc:start": "cd docs/ && bundle exec jekyll serve --config _config-development.yml",
"doc:start:fast": "cd docs/ && bundle exec jekyll serve --config _config-development.yml --incremental",
"doc:gem:install": "cd docs/ && bundle install",
"lint": "esw src/ -w --ext .ts --ext .tsx",
"lint:once": "eslint src/ --ext .ts --ext .tsx",
"lint:fix": "eslint src/ --ext .ts --ext .tsx --fix",
"lint:fix:preview": "eslint src/ --ext .ts --ext .tsx --fix-dry-run",
"lint:once": "TIMING=1 eslint src/ --ext .ts --ext .tsx",
"lint:fix": "TIMING=1 eslint src/ --ext .ts --ext .tsx --fix",
"lint:fix:preview": "TIMING=1 eslint src/ --ext .ts --ext .tsx --fix-dry-run",
"tsclint": "npx tsc --noEmit --skipLibCheck",
"prettier": "prettier-eslint --write $PWD/'src/**/*.[jt]s?(x)' && yarn lint:fix",
"format": "prettier --write src/**/*.{js,jsx,ts,tsx}",
"lint": "prettier-eslint --write \"$PWD/src/components/i18n/I18nLink.{js,jsx,ts,tsx}\" --eslint-config-path .eslintrc.yml --trailing-comma es5 --bracket-spacing",
"test": "NODE_ENV=test jest --watchAll",
"test:once": "NODE_ENV=test jest",
"test:coverage": "NODE_ENV=test jest --coverage",
Expand Down Expand Up @@ -151,15 +154,20 @@
"cypress": "4.5.0",
"del-cli": "3.0.1",
"eslint": "7.0.0",
"eslint-config-airbnb-typescript-prettier": "2.1.1",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-jest": "23.13.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "3.1.3",
"eslint-plugin-react": "7.20.0",
"eslint-plugin-react-hooks": "4.0.2",
"eslint-watch": "6.0.1",
"jest": "26.0.1",
"jest-extended": "0.11.5",
"node-mocks-http": "1.8.1",
"now": "17.1.1",
"prettier": "2.0.5",
"prettier-eslint-cli": "5.0.0",
"react-test-renderer": "16.13.1",
"ts-jest": "26.0.0",
"typescript": "3.9.2",
Expand Down
7 changes: 2 additions & 5 deletions src/components/pageLayouts/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ const Footer: React.FunctionComponent<Props> = () => {
},
];

// Resolve values, handle multiple fallback levels
const copyrightOwner = getValueFallback([
{ record: customer, key: 'label' },
]);
const currentYear = (new Date()).getFullYear();
const copyrightOwner = customer?.label;
const currentYear = new Date().getFullYear();

return (
<div
Expand Down
Loading