diff --git a/.eslintrc.js b/.eslintrc.js index 86b072c4..ecb60225 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,6 +3,7 @@ module.exports = { parserOptions: { sourceType: 'module', ecmaVersion: 2018, + project: './tsconfig.test.json', }, env: { jest: true, @@ -11,11 +12,10 @@ module.exports = { browser: true, page: true, }, - plugins: ['jest'], + plugins: ['jest', 'unused-imports'], rules: { 'array-bracket-newline': ['error', 'consistent'], strict: ['error', 'safe'], - curly: 'error', 'block-scoped-var': 'error', complexity: 'warn', 'default-case': 'error', @@ -27,6 +27,7 @@ module.exports = { 'no-case-declarations': 'error', 'no-console': 'error', 'no-constant-condition': 'error', + 'no-continue': 'warn', 'no-div-regex': 'error', 'no-empty': 'warn', 'no-empty-pattern': 'error', @@ -41,7 +42,6 @@ module.exports = { 'require-yield': 'error', 'max-nested-callbacks': ['error', 4], 'max-depth': ['error', 4], - 'require-await': 'error', 'space-before-function-paren': [ 'error', { @@ -72,17 +72,36 @@ module.exports = { requireLast: true, }, singleline: { - delimiter: 'comma', + delimiter: 'semi', requireLast: false, }, }, ], + '@typescript-eslint/ban-ts-comment': [ + 'error', + { + 'ts-expect-error': 'allow-with-description', + 'ts-ignore': 'allow-with-description', + 'ts-nocheck': 'allow-with-description', + 'ts-check': 'allow-with-description', + minimumDescriptionLength: 6, + }, + ], + 'require-await': 'off', + '@typescript-eslint/promise-function-async': 'error', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@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: '^_' }, + ], }, overrides: [ { files: ['*.spec.ts'], rules: { - // '@typescript-eslint/ban-ts-ignore': 'off', 'max-nested-callbacks': ['error', 10], // allow describe/it nesting }, }, diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..176a458f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore index 4953a97a..8890ce66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -lib - # Logs logs *.log +# OS files +.DS_Store + # Runtime data pids *.pid @@ -19,17 +20,11 @@ coverage # node-waf configuration .lock-wscript -#babel RC -.babelrc.js - build dist # Dependency directory node_modules -# Test data -test/data/* -!test/data/.gitkeep -!test/data/manifest -!test/data/TestIdentity.* +# Generated files +docs diff --git a/.huskyrc b/.huskyrc index 2a4718c2..474e5a13 100644 --- a/.huskyrc +++ b/.huskyrc @@ -2,4 +2,4 @@ "hooks": { "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } -} +} \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..5dfd3c7e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,13 @@ +{ + "printWidth": 120, + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "semi": false, + "singleQuote": true, + "quoteProps": "as-needed", + "trailingComma": "all", + "endOfLine": "lf", + "arrowParens": "avoid", + "proseWrap": "always" +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..7c8983b7 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,61 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make +participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, +disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, +socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +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 + +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 + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take +appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, +issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the +project or its community in public spaces. Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting as an appointed representative at an +online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at +info@ethswarm.org. All complaints will be reviewed and investigated and will result in a response that is deemed +necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to +the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent +repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq diff --git a/LICENSE b/LICENSE index aa9623f7..4dc6dd1e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,27 +1,29 @@ -Copyright (c) 2020 The Swarm Authors. All rights reserved. +BSD 3-Clause License + +Copyright (c) 2022, The Swarm Authors +All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Swarm nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/commitlint.config.js b/commitlint.config.js index 84dcb122..993f70fc 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,3 +1,6 @@ module.exports = { extends: ['@commitlint/config-conventional'], -}; + rules: { + 'body-max-line-length': [0, 'always', Infinity], // disable commit body length restriction + }, +}