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 - an opinionated code formatter #932

Merged
merged 2 commits into from
Feb 13, 2020
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

bin/admin
deploy
migrations/archived
public
scripts
modules/core/server/views/email-templates/
modules/core/server/views/email-templates-text/
modules/core/server/views/facebook-notifications/
.github/**/*.md
84 changes: 40 additions & 44 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const semver = require('semver');

// Converts semver range `~16.6.0` to strict version `16.6.0`
const reactVersion = semver.coerce(require('./package.json').dependencies.react).version;
const reactVersion = semver.coerce(require('./package.json').dependencies.react)
.version;

const defaultRules = {
const rules = {
'comma-dangle': [2, 'always-multiline'],
'comma-spacing': [2, { before: false, after: true }],
curly: [2, 'multi-line'],
eqeqeq: [2, 'smart'],
'guard-for-in': 2,
indent: [2, 2, { SwitchCase: 1, VariableDeclarator: { var: 2, let: 2, const: 3 } }],
'key-spacing': [2, { beforeColon: false, afterColon: true }],
'keyword-spacing': [2, { before: true, after: true }],
'new-cap': [2, { newIsCapExceptions: ['acl.memoryBackend', 'acl'] }],
Expand All @@ -26,48 +25,40 @@ const defaultRules = {
'object-curly-spacing': [2, 'always'],
'one-var': [2, 'never'],
'one-var-declaration-per-line': [2, 'always'],
'semi': [2, 'always'],
'space-before-function-paren': ['error', {
'anonymous': 'always',
'named': 'never',
'asyncArrow': 'always'
}],
'space-in-parens': [2, 'never'],
semi: [2, 'always'],
'spaced-comment': [2, 'always'],
strict: [2, 'never'],
'quote-props': 0,
quotes: [1, 'single'],
'wrap-iife': [2, 'outside'],
'no-var': 2,
'prefer-const': 2,
'arrow-spacing': [2, { before: true, after: true }],
'require-atomic-updates': 0,
'import/first': 2,
'prettier/prettier': 2,
};

module.exports = {
extends: [
'eslint:recommended',
'plugin:import/errors'
],
rules: defaultRules,
plugins: [
'angular',
'react',
'import'
'plugin:import/errors',
// Make sure these Prettier ones are last items on this list
'plugin:prettier/recommended',
'prettier/babel',
],
rules,
plugins: ['angular', 'react', 'import', 'prettier'],
settings: {
'import/resolver': {
webpack: {
config: __dirname + '/config/webpack/webpack.config.js'
}
}
config: __dirname + '/config/webpack/webpack.config.js',
},
},
},
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 2018
ecmaVersion: 2018,
},
parser: 'babel-eslint',
overrides: [
Expand Down Expand Up @@ -134,7 +125,7 @@ module.exports = {
'angular/typecheck-number': 2,
'angular/typecheck-object': 2,
'angular/typecheck-string': 2,
'angular/window-service': 2
'angular/window-service': 2,
},
settings: {
angular: 1,
Expand All @@ -154,7 +145,7 @@ module.exports = {
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
sourceType: 'module',
},
},

Expand All @@ -170,29 +161,35 @@ module.exports = {
'modules/**/client/api/**',
'modules/**/client/utils/**',
'modules/core/client/services/photos.service.js',
'modules/references/tests/client/**'
'modules/references/tests/client/**',
],
env: {
browser: true,
},
extends: 'plugin:react/recommended',
extends: [
'plugin:react/recommended',
// Make sure these Prettier ones are last items on this list
'plugin:prettier/recommended',
'prettier/react',
'prettier/babel',
],
settings: {
react: {
version: reactVersion
}
version: reactVersion,
},
},
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module'
sourceType: 'module',
},
rules: {
'react/no-access-state-in-setstate': 2,
'no-multi-assign': 2,
}
},
},

/**
Expand All @@ -207,12 +204,15 @@ module.exports = {
extends: [
'plugin:react/recommended',
'plugin:testing-library/react',
'plugin:jest-dom/recommended'
'plugin:jest-dom/recommended',
// Make sure these Prettier ones are last items on this list
'prettier',
'prettier/react',
],
settings: {
react: {
version: reactVersion
}
version: reactVersion,
},
},
env: {
browser: true,
Expand All @@ -237,19 +237,15 @@ module.exports = {
],
env: {
node: true,
mocha: true
}
mocha: true,
},
},

/**
* Overrides for CLI scripts and application config
*/
{
files: [
'bin/**',
'config/**',
'migrations/**',
],
files: ['bin/**', 'config/**', 'migrations/**'],
env: {
node: true,
},
Expand All @@ -258,5 +254,5 @@ module.exports = {
'no-process-exit': 0,
},
},
]
],
};
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
singleQuote: true
trailingComma: all
jsxBracketSameLine: false
semi: true
arrowParens: avoid
bracketSpacing: true
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
27 changes: 13 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

Refer to the [Ubuntu Code of Conduct](http://www.ubuntu.com/about/about-ubuntu/conduct) for guidance on how to contribute, particularly the following points:

* Be considerate
* Be respectful
* Take responsibility for our words and our actions
* Be collaborative
* Value decisiveness, clarity and consensus
* Ask for help when unsure
* Step down considerately
- Be considerate
- Be respectful
- Take responsibility for our words and our actions
- Be collaborative
- Value decisiveness, clarity and consensus
- Ask for help when unsure
- Step down considerately

Our code of conduct might be described as follows.

* Be pragmatic.
* Be nice to people.
* Show respect for those who do the work.
* When in doubt, defer to those with more experience, who have contributed for longer, and support their decisions.
* [We believe](https://www.trustroots.org/about) in beauty, simplicity and transparency.
* We emphasize community.
- Be pragmatic.
- Be nice to people.
- Show respect for those who do the work.
- When in doubt, defer to those with more experience, who have contributed for longer, and support their decisions.
- [We believe](https://www.trustroots.org/about) in beauty, simplicity and transparency.
- We emphasize community.

## Not a discussion forum

Expand All @@ -34,4 +34,3 @@ We value getting things done attitude. Arguments about minor issues shouldn't ge
## Real life interaction

We highly value real life interaction. Both within the network as well as among technical contributors. If possible, try to meet up with other Trustroots contributors in real life. You can connect your Trustroots profile to your GitHub account to facilitate such connections.

1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining
Expand Down
12 changes: 6 additions & 6 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Please send any issue that you feel affects the
security of Trustroots to **hello@trustroots.org** or [via our contact form](https://www.trustroots.org/contact).

If we do not respond promptly, please send us a quick
message *without details* to one of the following:
message _without details_ to one of the following:

* An issue at [GitHub](https://github.com/Trustroots/trustroots/issues)
* Message [@trustroots](https://twitter.com/trustroots) on Twitter.
* Give us a heads up on IRC in [#trustroots](https://webchat.freenode.net/?channels=trustroots) on Freenode.
- An issue at [GitHub](https://github.com/Trustroots/trustroots/issues)
- Message [@trustroots](https://twitter.com/trustroots) on Twitter.
- Give us a heads up on IRC in [#trustroots](https://webchat.freenode.net/?channels=trustroots) on Freenode.

## Bug Bounties

Expand All @@ -19,8 +19,8 @@ We are [a non-profit](https://www.trustroots.org/foundation), open source, volun

## History

* December 24, 2019 [Check for user id before modifying offer ](https://github.com/Trustroots/trustroots/pull/1011), kudos [Kenny Flannery](https://github.com/kenflannery)
- December 24, 2019 [Check for user id before modifying offer ](https://github.com/Trustroots/trustroots/pull/1011), kudos [Kenny Flannery](https://github.com/kenflannery)

## See also

* https://www.trustroots.org/.well-known/security.txt
- https://www.trustroots.org/.well-known/security.txt
13 changes: 8 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const isDevelopment = process.env.NODE_ENV === 'development';

module.exports = {
presets: [
['@babel/preset-env', {
corejs: 2,
modules: 'commonjs',
useBuiltIns: 'usage',
}],
[
'@babel/preset-env',
{
corejs: 2,
modules: 'commonjs',
useBuiltIns: 'usage',
},
],
['@babel/preset-react'],
],
plugins: compact([
Expand Down
5 changes: 1 addition & 4 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# bin

db-drop.js - probably drops the database
Expand All @@ -8,12 +6,11 @@ ensure-uploads-dir-exists.js - ?
install-deps.js - ?

only for NDA signed folks:

- dumpfetch.sh - fetches the production database to your local machine
- dumpimport.sh - puts the most recently fetched prod db onto your local mongo
- privacy.mongo - removes some private data and sets a standard password



## admin

Some admin related code, some of this can disappear once we have more
Expand Down
4 changes: 2 additions & 2 deletions bin/db-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if (process.env.NODE_ENV === 'production') {
// Use mongoose configuration
const mongooseService = require('../config/lib/mongoose.js');

mongooseService.connect(function (db) {
mongooseService.dropDatabase(db, function () {
mongooseService.connect(function(db) {
mongooseService.dropDatabase(db, function() {
mongooseService.disconnect();
});
});
Loading