Skip to content

Commit

Permalink
chore: configure eslint and fix lint errors (#84)
Browse files Browse the repository at this point in the history
The lint check is now part of the "build" GH workflow.

The configuration is duplicated from
process-analytics/bpmn-visualization-js@48f63c2
In the future, the project may use a shared eslint configuration to
avoid duplication between repositories.
  • Loading branch information
tbouffard authored Aug 24, 2023
1 parent a72463c commit d6d501d
Show file tree
Hide file tree
Showing 17 changed files with 2,990 additions and 279 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 180
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,adoc}]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
bin/
config/
dist/
node_modules/
69 changes: 69 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2021 Bonitasoft S.A.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

module.exports = {
root: true,
plugins: ['notice'],
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
rules: {
'notice/notice': ['error', { templateFile: 'config/license-header.js', onNonMatchingHeader: 'replace' }],
'no-console': ['error', { allow: ['warn', 'error'] }],
},
overrides: [
// typescript
{
files: ['*.ts'],
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
// This setting is required if you want to use rules which require type information
// https://typescript-eslint.io/packages/parser/#project
project: ['./packages/**/tsconfig.json', './tsconfig.eslint.json'],
},
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
},
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/consistent-type-exports': [
'error',
{
fixMixedExportsWithInlineTypeSpecifier: true,
},
],
'@typescript-eslint/consistent-type-imports': ['error'],
},
},
],
};
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ jobs:
run: npm run build -w packages/addons
- name: Check TypeScript Support
run: npm test -w packages/check-ts-support
- name: Check Lint
run: npm run lint-check
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
arrowParens:"avoid",
endOfLine:"auto"
};
15 changes: 15 additions & 0 deletions config/license-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Copyright <%= YEAR %> Bonitasoft S.A.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Loading

0 comments on commit d6d501d

Please sign in to comment.