Skip to content

Commit

Permalink
Fixed node config
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Apr 3, 2022
1 parent a72c21b commit 30abb02
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
5 changes: 2 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"extends": "./eslint-config-base.js",
"extends": "./eslint-config-node.js",
"env": {
"commonjs": true
},
"rules": {
"no-magic-numbers": "off",
"object-shorthand": "off",
"prefer-arrow-callback": "off",
"quote-props": ["error", "consistent"]
}
}
}
13 changes: 12 additions & 1 deletion eslint-config-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {
rules: {
'no-console': 'off',

'n/no-missing-import': 'off',
'n/no-missing-require': 'off',
'n/no-path-concat': 'error',
'n/callback-return': 'error',
'n/prefer-global/buffer': 'error',
Expand All @@ -23,5 +25,14 @@ module.exports = {
'n/prefer-global/url': 'error',
'n/prefer-promises/dns': 'error',
'n/prefer-promises/fs': 'error'
}
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
rules: {
'n/no-unsupported-features/es-syntax': 'off'
}
}
]
};
6 changes: 6 additions & 0 deletions helpers/make-naming-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const configs = [
'modifiers': ['const', 'global'],
'format': ['camelCase', 'UPPER_CASE']
},
{
// readonly class properties can be UPPER_CASE - both static and non-static - eg. class type/object type, class-scope constants
'selector': 'classProperty',
'modifiers': ['readonly'],
'format': ['camelCase', 'UPPER_CASE']
},
{
// unused parameters start with _
'selector': 'parameter',
Expand Down
21 changes: 12 additions & 9 deletions tests/run-tests.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/* eslint-env node */
/* eslint-disable no-console */
/* eslint
n/no-unsupported-features/es-builtins: ["error", { version: ">=16" }],
security-node/detect-unhandled-async-errors: "off"
*/

const { ESLint } = require('eslint');
const fs = require('fs');
const path = require('path');

const { ESLint } = require('eslint');
require('exit-code');

/**
* @returns {promise is PromiseRejectedResult}
*/
function filterRejected(promise) {
return promise.status === 'rejected'
return promise.status === 'rejected';
}

async function getErrors(configFile) {
Expand All @@ -26,11 +29,11 @@ async function getErrors(configFile) {
const exts = ['js', 'jsx', 'ts', 'tsx', 'json', 'jsonc', 'jsonx'].map(ext => `file.${ext}`);
const files = ['tsconfig.json', 'jsconfig.json'].map(ext => `file.${ext}`);

const results = await Promise.allSettled([ ...exts, ...files ].map(filePath => cli.lintText('', { filePath })));
const rejectReasons = results.filter(filterRejected).map(promise => promise.reason)
const results = await Promise.allSettled([...exts, ...files].map(filePath => cli.lintText('', { filePath })));
const rejectReasons = results.filter(filterRejected).map(promise => promise.reason);

if (rejectReasons.length > 0) {
throw rejectReasons
throw rejectReasons;
}
}

Expand All @@ -44,8 +47,8 @@ async function run() {
} catch (errors) {
console.error('Error in config file', f.name);
console.error(errors);
process.exitCode = 2

process.exitCode = 2;
}
});
}
Expand Down

0 comments on commit 30abb02

Please sign in to comment.