Skip to content

Commit

Permalink
Switch ESLint configuration to more closely match Signal-Desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
jrose-signal committed Nov 11, 2020
1 parent 23bbf7a commit 7bfee71
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
singleQuote: true,
trailingComma: 'all',
trailingComma: 'es5',
};
46 changes: 28 additions & 18 deletions node/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ module.exports = {

parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2018,
sourceType: 'module',
},

settings: {
'import/core-modules': ['electron'],
},

plugins: ['header', 'mocha', 'more', '@typescript-eslint'],
plugins: ['header', 'import', 'mocha', 'more', '@typescript-eslint'],

extends: ['airbnb-typescript/base'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],

rules: {
'header/header': [
Expand All @@ -27,6 +35,17 @@ module.exports = {
],
],

'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],

// prevents us from accidentally checking in exclusive tests (`.only`):
'mocha/no-exclusive-tests': 'error',

Expand All @@ -39,6 +58,9 @@ module.exports = {
// useful for unused or internal fields
'no-underscore-dangle': 'off',

// useful for unused parameters
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],

// though we have a logger, we still remap console to log to disk
'no-console': 'error',

Expand All @@ -51,23 +73,11 @@ module.exports = {
{ avoidEscape: true, allowTemplateLiterals: false },
],

// We prefer named exports
'import/prefer-default-export': 'off',

'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',

// Prettier overrides:
'arrow-parens': 'off',
'function-paren-newline': 'off',
'max-len': [
'error',
{
// Prettier generally limits line length to 80 but sometimes goes over.
// The `max-len` plugin doesn’t let us omit `code` so we set it to a
// high value as a buffer to let Prettier control the line length:
code: 999,
// We still want to limit comments as before:
comments: 90,
ignoreUrls: true,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'error',
},
};
5 changes: 2 additions & 3 deletions node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

import bindings = require('bindings'); // eslint-disable-line @typescript-eslint/no-require-imports
import * as SignalClient from './libsignal_client';
import bindings = require('bindings'); // eslint-disable-line import/order, @typescript-eslint/no-require-imports

// eslint-disable-next-line import/prefer-default-export
export const { PrivateKey } = bindings(
'libsignal_client',
'libsignal_client'
) as typeof SignalClient;
2 changes: 1 addition & 1 deletion node/test/PublicAPITest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('SignalClient', () => {
assert(a.serialize().equals(a.serialize()), 'repeatable');
assert(
!a.serialize().equals(b.serialize()),
'different for different keys',
'different for different keys'
);
});
});
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@
"electron-build-env": "^0.2.0",
"electron-mocha": "8.1.1",
"eslint": "^7.12.1",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-header": "^3.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-more": "^1.0.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"mocha": "7.1.1",
"node-gyp": "^7.1.2",
"prettier": "1.19.1",
Expand Down
Loading

0 comments on commit 7bfee71

Please sign in to comment.