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

chore(eslint): use unicorn/recommended rules #2824

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 8 additions & 42 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ module.exports = {
plugins: ['notice', 'unicorn', 'import'],
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.
'plugin:import/recommended',
'plugin:unicorn/recommended',
csouchet marked this conversation as resolved.
Show resolved Hide resolved
'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
Expand All @@ -40,47 +41,6 @@ module.exports = {
},
},
],
'unicorn/prevent-abbreviations': 'error',
'unicorn/prefer-query-selector': 'error',
'unicorn/prefer-add-event-listener': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/prefer-logical-operator-over-ternary': 'error',
'unicorn/consistent-function-scoping': 'error',
'unicorn/prefer-at': 'error',
'unicorn/prefer-blob-reading-methods': 'error',
'unicorn/prefer-code-point': 'error',
'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-dom-node-dataset': 'error',
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/prefer-number-properties': 'error',
'unicorn/prefer-set-has': 'error',
'unicorn/prefer-set-size': 'error',
'unicorn/prefer-string-slice': 'error',
'unicorn/no-negated-condition': 'error',
'unicorn/no-array-callback-reference': 'error',
'unicorn/no-array-method-this-argument': 'error',
'unicorn/no-array-push-push': 'error',
'unicorn/no-array-reduce': 'error',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-unreadable-array-destructuring': 'error',
'unicorn/no-useless-length-check': 'error',
'unicorn/explicit-length-check': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-array-index-of': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/require-array-join-separator': 'error',
'unicorn/numeric-separators-style': 'error',
'unicorn/no-zero-fractions': 'error',
'unicorn/no-useless-switch-case': 'error',
'unicorn/prefer-switch': 'error',
'unicorn/switch-case-braces': 'error',
'unicorn/prefer-spread': 'error',
'unicorn/text-encoding-identifier-case': 'error',
'import/newline-after-import': ['error', { count: 1 }],
'import/first': 'error',
'import/order': [
Expand All @@ -95,6 +55,12 @@ module.exports = {
},
},
],
'unicorn/prefer-keyboard-event-key': 'off', // 'key' doesn't exist in the used ES version
'unicorn/prefer-module': 'off', // We don't want to change a working configuration
'unicorn/prefer-string-replace-all': 'off', // String#replaceAll() doesn't exist in the used ES version
'unicorn/no-new-array': 'off', // In contradiction with unicorn/new-for-builtins: Use `new Array()` instead of `Array()`
'unicorn/no-null': 'off', // We don't know the impact on mxGraph code
'unicorn/no-useless-undefined': 'off', // The "undefined" value is useful where we use it and change some mxGraph code
},
overrides: [
// typescript
Expand Down
2 changes: 1 addition & 1 deletion dev/ts/shared/internal-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function fetchBpmnContent(url: string): Promise<string> {
log(`Fetching BPMN content from url ${url}`);
const response = await fetch(url);
if (!response.ok) {
throw Error(`HTTP status ${response.status}`);
throw new Error(`HTTP status ${response.status}`);
}
return await response.text();
}
1 change: 1 addition & 0 deletions src/model/bpmn/internal/shape/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ShapeBpmnElementKind, ShapeBpmnEventDefinitionKind } from './kinds';
* @category BPMN
* @experimental
*/
// eslint-disable-next-line unicorn/no-static-only-class -- Breaking change on API
export class ShapeUtil {
static isEvent(kind: ShapeBpmnElementKind | string): boolean {
return isKindOf(EVENT_KINDS, kind);
Expand Down
2 changes: 1 addition & 1 deletion test/config/ts-jest.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

// Inspired from https://kulshekhar.github.io/ts-jest/docs/getting-started/paths-mapping/
const fs = require('fs');
const fs = require('node:fs');

const JSON5 = require('json5');
const { pathsToModuleNameMapper } = require('ts-jest');
Expand Down
Loading