Skip to content

Commit

Permalink
Merge pull request #21 from dusk-network/feature-20
Browse files Browse the repository at this point in the history
Add Dusk prettier config and format project
  • Loading branch information
kieranhall authored Feb 26, 2024
2 parents 660c5ca + 81a73f2 commit f903963
Show file tree
Hide file tree
Showing 16 changed files with 324 additions and 4,009 deletions.
8 changes: 2 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
root = true

[*]
indent_style = tab
indent_size = 4
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2
22 changes: 10 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"./js/index.js"
],
"plugins": [],
"root": true,
"rules": {},
"settings": {}
env: {
browser: true,
es6: true,
node: true,
},
extends: ["./js/index.js"],
plugins: [],
root: true,
rules: {},
settings: {},
};
5 changes: 2 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: check

on:
push:
branches: [ main ]
branches: [main]

pull_request:

jobs:
checks:

runs-on: ubuntu-latest

strategy:
Expand All @@ -22,7 +21,7 @@ jobs:
uses: actions/checkout@v3

- name: Installing dev dependencies
run: npm ci
run: npm install

- name: Checking rules
run: npm run check-rules
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Dependencies
node_modules
package-lock.json

# Env files
.env
Expand Down
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import duskJsPrettierConfig from "@dusk-network/prettier-config/js/index.js";

export default {
...duskJsPrettierConfig,
};
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ npm i -D @dusk-network/eslint-config
```

The package requires the following peer dependencies:

- [`eslint`](https://github.com/eslint/eslint) `>=8`
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) `>=2`

Expand Down
146 changes: 74 additions & 72 deletions js/base.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,76 @@
module.exports = {
rules: {
"array-callback-return": ["error", { allowImplicit: true }],
"class-methods-use-this": 0,
"complexity": ["error", 14],
"consistent-return": ["error", { "treatUndefinedAsUnspecified": false }],
"consistent-this": "error",
"curly": ["error", "all"],
"default-case": "error",
"dot-notation": "error",
"eqeqeq": "error",
"max-depth": ["error", 3],
"max-nested-callbacks": ["error", 3],
"max-params": ["error", 5],
"max-statements": ["error", 15, { "ignoreTopLevelFunctions": true }],
"new-cap": ["error", { "newIsCap": true, "properties": true }],
"no-alert": "error",
"no-array-constructor": "error",
"no-caller": "error",
"no-console": "error",
"no-duplicate-imports": ["error", { "includeExports": true }],
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-nested-ternary": 0,
"no-new": "error",
"no-octal-escape": "error",
"no-param-reassign": 0,
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": ["error", "event"],
"no-return-assign": ["error", "always"],
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": [
"error", {
"allowShortCircuit": true,
"allowTernary": false
}
],
"no-unused-vars": [2, { "args": "after-used" }],
"no-use-before-define": [0, "nofunc"],
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-var": "error",
"no-with": "error",
"prefer-const": [
"error", {
"destructuring": "any",
"ignoreReadBeforeAssign": false
}
],
"radix": "error",
"strict": ["error", "function"],
"yoda": "error"
}
rules: {
"array-callback-return": ["error", { allowImplicit: true }],
"class-methods-use-this": 0,
complexity: ["error", 14],
"consistent-return": ["error", { treatUndefinedAsUnspecified: false }],
"consistent-this": "error",
curly: ["error", "all"],
"default-case": "error",
"dot-notation": "error",
eqeqeq: "error",
"max-depth": ["error", 3],
"max-nested-callbacks": ["error", 3],
"max-params": ["error", 5],
"max-statements": ["error", 15, { ignoreTopLevelFunctions: true }],
"new-cap": ["error", { newIsCap: true, properties: true }],
"no-alert": "error",
"no-array-constructor": "error",
"no-caller": "error",
"no-console": "error",
"no-duplicate-imports": ["error", { includeExports: true }],
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-nested-ternary": 0,
"no-new": "error",
"no-octal-escape": "error",
"no-param-reassign": 0,
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": ["error", "event"],
"no-return-assign": ["error", "always"],
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": [
"error",
{
allowShortCircuit: true,
allowTernary: false,
},
],
"no-unused-vars": [2, { args: "after-used" }],
"no-use-before-define": [0, "nofunc"],
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-var": "error",
"no-with": "error",
"prefer-const": [
"error",
{
destructuring: "any",
ignoreReadBeforeAssign: false,
},
],
radix: "error",
strict: ["error", "function"],
yoda: "error",
},
};
6 changes: 3 additions & 3 deletions js/import.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
rules: {
"import/no-duplicates": 0
}
rules: {
"import/no-duplicates": 0,
},
};
30 changes: 13 additions & 17 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
const rules = [
"./base",
"./import",
"./style"
].map(require.resolve);
const rules = ["./base", "./import", "./style"].map(require.resolve);

module.exports = {
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"prettier",
...rules,
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
},
rules: {}
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"prettier",
...rules,
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {},
};
31 changes: 17 additions & 14 deletions js/style.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
module.exports = {
rules: {
"camelcase": "error",
"no-warning-comments": ["error", { "location": "anywhere" }],
"one-var": ["error", "never"],
"prefer-template": "error",
"sort-imports": ["error", {
"allowSeparatedGroups": true,
"ignoreCase": false,
"ignoreDeclarationSort": true,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}],
"sort-keys": ["error", "asc", { "caseSensitive": false, "natural": true }]
}
rules: {
camelcase: "error",
"no-warning-comments": ["error", { location: "anywhere" }],
"one-var": ["error", "never"],
"prefer-template": "error",
"sort-imports": [
"error",
{
allowSeparatedGroups: true,
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
},
],
"sort-keys": ["error", "asc", { caseSensitive: false, natural: true }],
},
};
Loading

0 comments on commit f903963

Please sign in to comment.