Skip to content

Commit

Permalink
add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jun 12, 2023
1 parent bf26387 commit cc2f2a1
Show file tree
Hide file tree
Showing 9 changed files with 3,242 additions and 596 deletions.
75 changes: 75 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'unicorn', 'import'],
extends: ['eslint:recommended'],
env: {
node: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
camelcase: ['error', { properties: 'never' }],
semi: ['error', 'never'],
indent: [2, 2],
eqeqeq: ['error', 'always'],

'prefer-const': 'error',
'no-multiple-empty-lines': [2, { max: 1, maxEOF: 1 }],
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-spacing': ['error', { before: false, after: true }],
'no-lonely-if': 'error',
'dot-notation': 'error',
'no-else-return': 'error',
'no-tabs': 'error',
'no-trailing-spaces': [
'error',
{
skipBlankLines: false,
ignoreComments: false,
},
],
'no-var': 'error',
'unicode-bom': ['error', 'never'],
curly: ['error', 'all'],
'object-curly-spacing': ['error', 'always'],
'keyword-spacing': ['error'],
'require-atomic-updates': 0,
'linebreak-style': ['error', 'unix'],
'unicorn/prefer-node-protocol': ['error'],
'import/extensions': ['error', 'ignorePackages'],
'no-restricted-syntax': [
'error',
'IfStatement > ExpressionStatement > AssignmentExpression',
],
'unicorn/prefer-ternary': 'error',
},
overrides: [
{
files: ['*.ts'],
rules: {
// see https://stackoverflow.com/questions/55280555/typescript-eslint-eslint-plugin-error-route-is-defined-but-never-used-no-un
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'no-undef': 'off',
// allow overloads
'no-redeclare': 'off',
},
},
{
files: ['*.test.ts'],
rules: {
'dot-notation': 'off',
},
},
],
}

module.exports = config
10 changes: 8 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ RUNME_PROJECT="" ./node_modules/runme/.bin/runme run clean compile
To run the entire test pipeline, call:

```sh { name=test }
RUNME_PROJECT="" ./node_modules/runme/.bin/runme run test:unit test:cjs
RUNME_PROJECT="" ./node_modules/runme/.bin/runme run test:lint test:unit test:cjs
```

This will run unit tests via Vitest:
This will run [Eslint](https://eslint.org/) checks:

```sh { name=test:lint }
npx eslint src tests
```

unit tests via [Vitest](https://vitest.dev/):

```sh { name=test:unit }
npx vitest --config ./vitest.config.ts
Expand Down
Loading

0 comments on commit cc2f2a1

Please sign in to comment.