Skip to content

Commit

Permalink
Merge pull request #2022 from aeternity/prettier
Browse files Browse the repository at this point in the history
Setup Prettier to format code
  • Loading branch information
davidyuk authored Sep 26, 2024
2 parents 58e3f43 + c664255 commit 6c2dbfe
Show file tree
Hide file tree
Showing 252 changed files with 12,153 additions and 9,596 deletions.
197 changes: 107 additions & 90 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ module.exports = {
es2021: true,
node: true,
},
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
],
extends: ['plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 13,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
'rulesdir',
],
plugins: ['@typescript-eslint', 'rulesdir', 'import'],
ignorePatterns: [
'dist', 'es', 'src/apis', 'docs/api', 'test/environment/ledger/browser',
'docs/examples', 'site', 'examples/browser/tools',
'dist',
'es',
'src/apis',
'docs/api',
'test/environment/ledger/browser',
'docs/examples',
'site',
'examples/browser/tools',
],
rules: {
'rulesdir/tsdoc-syntax': 'error',
Expand All @@ -35,90 +35,107 @@ module.exports = {
'no-await-in-loop': 'off',
'no-void': 'off',
},
overrides: [{
files: '*.ts',
extends: [
'airbnb-typescript/base',
// TODO: enable extends from below
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parserOptions: {
project: './tsconfig.eslint.json',
},
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' },
overrides: [
{
files: '*.ts',
extends: [
'airbnb-typescript/base',
// TODO: enable extends from below
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/explicit-function-return-type': ['error', {
allowExpressions: true,
allowHigherOrderFunctions: true,
allowTypedFunctionExpressions: true,
allowDirectConstAssertionInArrowFunctions: true,
}],
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
// by default allowSingleExtends is false that breaks interfaces for documentation
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': ['error', { ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false }],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
'@typescript-eslint/strict-boolean-expressions': ['error', {
allowString: false,
allowNumber: false,
allowNullableObject: false,
allowNullableBoolean: false,
allowNullableString: false,
allowNullableNumber: false,
allowAny: false,
}],
'@typescript-eslint/type-annotation-spacing': 'error',
// TODO: enable rules from below
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-types': 'off',
parserOptions: {
project: './tsconfig.eslint.json',
},
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' },
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowHigherOrderFunctions: true,
allowTypedFunctionExpressions: true,
allowDirectConstAssertionInArrowFunctions: true,
},
],
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
// by default allowSingleExtends is false that breaks interfaces for documentation
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{ ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false },
],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowString: false,
allowNumber: false,
allowNullableObject: false,
allowNullableBoolean: false,
allowNullableString: false,
allowNullableNumber: false,
allowAny: false,
},
],
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/indent': 'off',
// TODO: enable rules from below
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-types': 'off',
},
},
}, {
files: 'tooling/**/*',
rules: {
'import/no-extraneous-dependencies': 'off',
'no-console': 'off',
{
files: 'tooling/**/*',
rules: {
'import/no-extraneous-dependencies': 'off',
'no-console': 'off',
},
},
}, {
files: 'test/**/*',
rules: {
'no-underscore-dangle': 'off',
// TODO: enable rules from below
'no-console': 'off',
{
files: 'test/**/*',
rules: {
'no-underscore-dangle': 'off',
// TODO: enable rules from below
'no-console': 'off',
},
},
}, {
files: 'examples/**/*',
rules: {
'no-console': 'off',
'no-alert': 'off',
'no-restricted-globals': 'off',
'import/no-unresolved': 'off',
{
files: 'examples/**/*',
rules: {
'no-console': 'off',
'no-alert': 'off',
'no-restricted-globals': 'off',
'import/no-unresolved': 'off',
},
},
}, {
files: 'examples/node/**/*',
rules: { 'no-restricted-syntax': 'off' },
}, {
files: ['tooling/**/*', 'examples/node/*', '**/*.config.js', '.eslintrc.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
{
files: 'examples/node/**/*',
rules: { 'no-restricted-syntax': 'off' },
},
}],
{
files: ['tooling/**/*', 'examples/node/*', '**/*.config.js', '.eslintrc.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
],
};
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -25,11 +25,11 @@ If applicable, add screenshots to help explain your problem.

**Please tell us about your environment:**

- Node Version: v0.0.0
- Protocol Version: 1
- Compiler version: v0.0.0
- VM Version: fate | fate2
- SDK Version: v0.0.0
- Python version: v3.7.0
- Node Version: v0.0.0
- Protocol Version: 1
- Compiler version: v0.0.0
- VM Version: fate | fate2
- SDK Version: v0.0.0
- Python version: v3.7.0

**Other information** (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. forum, telegram, etc)
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "CodeQL"
name: CodeQL

on:
push:
branches: [ "develop", "master" ]
branches: [develop, master]
pull_request:
branches: [ "develop" ]
branches: [develop]
schedule:
- cron: "59 6 * * 2"
- cron: 59 6 * * 2

jobs:
analyze:
Expand All @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ javascript ]
language: [javascript]

steps:
- name: Checkout
Expand All @@ -38,4 +38,4 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
category: /language:${{ matrix.language }}
2 changes: 1 addition & 1 deletion .github/workflows/docs-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Publish develop docs
on:
push:
branches: ['develop']
branches: [develop]

jobs:
main:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ jobs:
main:
runs-on: ubuntu-22.04
steps:
- run: |
wget -q https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_25.2.3-1~ubuntu~jammy_amd64.deb
sudo apt install ./esl-erlang_25.2.3-1~ubuntu~jammy_amd64.deb
- run: sudo apt install erlang
- uses: actions/checkout@v4
with:
fetch-depth: 100
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module.exports = {
extension: '.js,.ts',
timeout: process.env.NETWORK ? '30s' : '6s',
ignore: 'test/environment/**',
}
};
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"singleQuote": true
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ JavaScript SDK for the revolutionary [æternity] blockchain, targeting the
## Guides & Examples

Introduction

- [Installation](docs/README.md)
- [Quick Start](docs/quick-start.md)

Usage guides:

- [AENS](docs/guides/aens.md) (æternity naming system)
- [Contracts](docs/guides/contracts.md)
- [Contract Events](docs/guides/contract-events.md)
Expand All @@ -29,8 +31,8 @@ Usage guides:
- [Error Handling](docs/guides/error-handling.md)
- [Low vs High level API](docs/guides/low-vs-high-usage.md)
- Wallet Interaction
- [Connect an æpp to a wallet](docs/guides/connect-aepp-to-wallet.md)
- [How to build a wallet](docs/guides/build-wallet.md)
- [Connect an æpp to a wallet](docs/guides/connect-aepp-to-wallet.md)
- [How to build a wallet](docs/guides/build-wallet.md)

There are also [examples](examples/README.md) that you can directly use and play with.

Expand Down
25 changes: 14 additions & 11 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
module.exports = {
presets: [
['@babel/preset-env', {
include: [
// compatibility with create-react-app@4
'@babel/plugin-proposal-nullish-coalescing-operator',
// compatibility with vue-cli-plugin-browser-extension@0.25
'@babel/plugin-proposal-logical-assignment-operators',
// compatibility with @vue/cli@4
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-private-methods',
],
}],
[
'@babel/preset-env',
{
include: [
// compatibility with create-react-app@4
'@babel/plugin-proposal-nullish-coalescing-operator',
// compatibility with vue-cli-plugin-browser-extension@0.25
'@babel/plugin-proposal-logical-assignment-operators',
// compatibility with @vue/cli@4
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-private-methods',
],
},
],
'@babel/preset-typescript',
],
plugins: [
Expand Down
9 changes: 6 additions & 3 deletions babel.esm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ config.presets

config.plugins.push(
['add-import-extension', { extension: 'mjs' }],
['import-globals', {
Buffer: { moduleName: 'buffer', exportName: 'Buffer' },
}],
[
'import-globals',
{
Buffer: { moduleName: 'buffer', exportName: 'Buffer' },
},
],
['transform-default-named-imports', { exclude: ['@scure/bip39'] }],
);
config.plugins = config.plugins.filter((p) => p !== 'babel-plugin-transform-import-meta');
Expand Down
Loading

0 comments on commit 6c2dbfe

Please sign in to comment.