Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: added code linting #473

Merged
merged 14 commits into from
Feb 2, 2024
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
112 changes: 112 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
parser: "@babel/eslint-parser"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why babel? Why do we need even changing the default parser? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

when i run npm run lint it gives the same error

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those errors seem genuine to me, and are errors we should fix in our code.

That screenshot about babel has nothing to do with this as far as I can see.

Copy link
Contributor Author

@Gmin2 Gmin2 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smoya i have reffered this and have used babel-eslint
I might be wrong here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That example uses React, which iirc uses Babel.

Thats the reason they are talking about babel.
We do not need any parser different than the default one.


env:
node: true
es6: true
mocha: true
browser: true

plugins:
- sonarjs

extends:
- eslint:recommended
- plugin:sonarjs/recommended

parserOptions:
requireConfigFile: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to make it work with async

Suggested change
requireConfigFile: false
requireConfigFile: false
ecmaVersion: 2018


rules:
# Ignore Rules
strict: 0
no-underscore-dangle: 0
no-mixed-requires: 0
no-process-exit: 0
no-warning-comments: 0
no-use-before-define: 0
curly: 0
no-multi-spaces: 0
no-alert: 0
consistent-return: 0
consistent-this: [0, self]
func-style: 0
max-nested-callbacks: 0
camelcase: 0
no-dupe-class-members: 0
security/detect-object-injection: 0
sonarjs/no-small-switch: 0
sonarjs/no-nested-template-literals: 0

# Warnings
no-debugger: 1
no-empty: 1
no-invalid-regexp: 1
no-unused-expressions: 1
no-native-reassign: 1
no-fallthrough: 1
sonarjs/cognitive-complexity: 1

# Errors
eqeqeq: 2
no-undef: 2
no-dupe-keys: 2
no-empty-character-class: 2
no-self-compare: 2
valid-typeof: 2
handle-callback-err: 2
no-shadow-restricted-names: 2
no-new-require: 2
no-mixed-spaces-and-tabs: 2
block-scoped-var: 2
no-else-return: 2
no-throw-literal: 2
no-void: 2
radix: 2
wrap-iife: [2, outside]
no-shadow: 0
no-path-concat: 2
valid-jsdoc: [0, {requireReturn: false, requireParamDescription: false, requireReturnDescription: false}]

# stylistic errors
no-spaced-func: 2
semi-spacing: 2
quotes: [2, 'single']
key-spacing: [2, { beforeColon: false, afterColon: true }]
indent: [2, 2]
no-lonely-if: 2
no-floating-decimal: 2
brace-style: [2, 1tbs, { allowSingleLine: true }]
comma-style: [2, last]
no-multiple-empty-lines: [2, {max: 1}]
no-nested-ternary: 2
operator-assignment: [2, always]
padded-blocks: [2, never]
quote-props: [2, as-needed]
keyword-spacing: [2, {'before': true, 'after': true, 'overrides': {}}]
space-before-blocks: [2, always]
array-bracket-spacing: [2, never]
computed-property-spacing: [2, never]
space-in-parens: [2, never]
space-unary-ops: [2, {words: true, nonwords: false}]
wrap-regex: 2
linebreak-style: 0
semi: [2, always]
arrow-spacing: [2, {before: true, after: true}]
no-class-assign: 2
no-const-assign: 2
no-this-before-super: 2
no-var: 2
object-shorthand: [2, always]
prefer-arrow-callback: 2
prefer-const: 2
prefer-spread: 2
prefer-template: 2

overrides:
- files:
- "test/**"
rules:
prefer-arrow-callback: 0
sonarjs/no-duplicate-string: 0
security/detect-object-injection: 0
security/detect-non-literal-fs-filename: 0
40 changes: 20 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module.exports = {
'schemas': {
'2.0.0': require('./schemas/2.0.0.json'),
'2.1.0': require('./schemas/2.1.0.json'),
'2.2.0': require('./schemas/2.2.0.json'),
'2.3.0': require('./schemas/2.3.0.json'),
'2.4.0': require('./schemas/2.4.0.json'),
'2.5.0': require('./schemas/2.5.0.json'),
'2.6.0': require('./schemas/2.6.0.json'),
'3.0.0': require('./schemas/3.0.0.json'),
},
'schemasWithoutId': {
'2.0.0': require('./schemas/2.0.0-without-$id.json'),
'2.1.0': require('./schemas/2.1.0-without-$id.json'),
'2.2.0': require('./schemas/2.2.0-without-$id.json'),
'2.3.0': require('./schemas/2.3.0-without-$id.json'),
'2.4.0': require('./schemas/2.4.0-without-$id.json'),
'2.5.0': require('./schemas/2.5.0-without-$id.json'),
'2.6.0': require('./schemas/2.6.0-without-$id.json'),
'3.0.0': require('./schemas/3.0.0-without-$id.json'),
}
schemas: {
'2.0.0': require('./schemas/2.0.0.json'),
'2.1.0': require('./schemas/2.1.0.json'),
'2.2.0': require('./schemas/2.2.0.json'),
'2.3.0': require('./schemas/2.3.0.json'),
'2.4.0': require('./schemas/2.4.0.json'),
'2.5.0': require('./schemas/2.5.0.json'),
'2.6.0': require('./schemas/2.6.0.json'),
'3.0.0': require('./schemas/3.0.0.json'),
},
schemasWithoutId: {
'2.0.0': require('./schemas/2.0.0-without-$id.json'),
'2.1.0': require('./schemas/2.1.0-without-$id.json'),
'2.2.0': require('./schemas/2.2.0-without-$id.json'),
'2.3.0': require('./schemas/2.3.0-without-$id.json'),
'2.4.0': require('./schemas/2.4.0-without-$id.json'),
'2.5.0': require('./schemas/2.5.0-without-$id.json'),
'2.6.0': require('./schemas/2.6.0-without-$id.json'),
'3.0.0': require('./schemas/3.0.0-without-$id.json'),
}
};
Loading