-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored JS and Svelte linting rules
- Loading branch information
1 parent
e82cfc4
commit 716f7a4
Showing
18 changed files
with
4,559 additions
and
3,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"./js/index.js" | ||
], | ||
"plugins": [], | ||
"root": true, | ||
"rules": {}, | ||
"settings": {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: check | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
pull_request: | ||
|
||
jobs: | ||
checks: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x, 18.x, 20.x] | ||
|
||
name: Node ${{ matrix.node-version }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Installing dev dependencies | ||
run: npm ci | ||
|
||
- name: Checking rules | ||
run: npm run check-rules | ||
|
||
- name: Linting | ||
run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# MacOS | ||
.DS_Store | ||
|
||
# Dependencies | ||
node_modules | ||
|
||
# Env files | ||
.env | ||
node_modules/ | ||
.env.* | ||
|
||
# Logs | ||
*.log | ||
npm-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
# dusk-eslint-config | ||
# Dusk ESLint rules | ||
|
||
> ESLint config use by Dusk Javascript apps. | ||
ESLint config used by [Dusk](https://dusk.network/) JavaScript apps. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm i -D eslint @dusk-network/eslint-config | ||
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` | ||
|
||
If you are using Svelte rules the package need the following optional dependency: | ||
|
||
- [`eslint-plugin-svelte`](https://github.com/sveltejs/eslint-plugin-svelte) `>=2` | ||
|
||
## Usage | ||
|
||
```json | ||
"eslintConfig": { | ||
"extends": "@dusk-network" | ||
} | ||
Add the rulesets you want in the `extends` section of your ESLint configuration file. | ||
|
||
e.g. to use both JS and Svelte's rules: | ||
|
||
```javascript | ||
// ... | ||
|
||
extends: [ | ||
"@dusk-network/eslint-config/js", | ||
"@dusk-network/eslint-config/svelte" | ||
] | ||
|
||
// ... | ||
``` | ||
|
||
# npm scripts | ||
|
||
- `npm run bump` updates version number using an interactive shell | ||
- `npm run check` checks for deprecated rules and performs the linting check | ||
- `npm run check-js` checks for deprecated JS rules | ||
- `npm run check-rules` checks for deprecated JS and Svelte rules | ||
- `npm run check-svelte` checks for deprecated Svelte rules | ||
- `npm run lint` performs the linting check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
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-location": ["error", "property"], | ||
"dot-notation": "error", | ||
"eqeqeq": "error", | ||
"func-call-spacing": ["error", "never"], | ||
"max-depth": ["error", 3], | ||
"max-len": ["error", { | ||
"code": 110, | ||
"comments": 110, | ||
"ignorePattern": "^ \\* @overview", | ||
"ignoreUrls": true | ||
}], | ||
"max-nested-callbacks": ["error", 3], | ||
"max-params": ["error", 5], | ||
"max-statements": ["error", 15, { "ignoreTopLevelFunctions": true }], | ||
"max-statements-per-line": ["error", { "max": 1 }], | ||
"new-cap": ["error", { "newIsCap": true, "properties": true }], | ||
"no-alert": "error", | ||
"no-array-constructor": "error", | ||
"no-caller": "error", | ||
"no-confusing-arrow": ["error", { "allowParens": true }], | ||
"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-multi-spaces": "error", | ||
"no-nested-ternary": 0, | ||
"no-new": "error", | ||
"no-new-object": "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-whitespace-before-property": "error", | ||
"no-with": "error", | ||
"prefer-const": [ | ||
"error", { | ||
"destructuring": "any", | ||
"ignoreReadBeforeAssign": false | ||
} | ||
], | ||
"radix": "error", | ||
"semi": ["error", "always"], | ||
"strict": ["error", "function"], | ||
"wrap-iife": ["error", "inside"], | ||
"yoda": "error" | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
rules: { | ||
"import/no-duplicates": 0 | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const rules = [ | ||
"./base", | ||
"./import", | ||
"./style" | ||
].map(require.resolve); | ||
|
||
module.exports = { | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:import/errors", | ||
"plugin:import/warnings", | ||
...rules | ||
], | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module" | ||
}, | ||
rules: {} | ||
}; |
Oops, something went wrong.