Skip to content

Commit

Permalink
Extend recommended plugin rules in all configs (#156)
Browse files Browse the repository at this point in the history
* Fix validate-script prettier violation logging
* Extend recommended plugin rules in all configs
* Delete some extraneous TypeScript rules
  • Loading branch information
rekmarks authored Apr 2, 2021
1 parent 9c6afdc commit 282ef52
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 29 deletions.
1 change: 1 addition & 0 deletions packages/mocha/rules-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
],
"mocha/no-async-describe": "error",
"mocha/no-exclusive-tests": "error",
"mocha/no-exports": "error",
"mocha/no-global-tests": "error",
"mocha/no-hooks": "off",
"mocha/no-hooks-for-single-case": "error",
Expand Down
2 changes: 2 additions & 0 deletions packages/mocha/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
mocha: true,
},

extends: ['plugin:mocha/recommended'],

rules: {
'mocha/handle-done-callback': 'error',
'mocha/max-top-level-suites': ['error', { limit: 1 }],
Expand Down
1 change: 1 addition & 0 deletions packages/nodejs/rules-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"no-process-exit": "off",
"node/callback-return": "error",
"node/exports-style": "error",
"node/file-extension-in-import": "off",
Expand Down
6 changes: 6 additions & 0 deletions packages/nodejs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = {
node: true,
},

extends: ['plugin:node/recommended'],

rules: {
// Possible Errors
'node/handle-callback-err': ['error', '^(err|error)$'],
Expand Down Expand Up @@ -48,5 +50,9 @@ module.exports = {
'node/prefer-global/url': 'error',
'node/prefer-promises/dns': 'error',
'node/prefer-promises/fs': 'error',

// Deprecated eslint core rule, erroneously enabled by recommended Node rules
// https://eslint.org/docs/rules/no-process-exit
'no-process-exit': 'off',
},
};
12 changes: 12 additions & 0 deletions packages/typescript/rules-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-for-in-array": "off",
Expand Down Expand Up @@ -100,6 +101,7 @@
"@typescript-eslint/typedef": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/unified-signatures": "error",
"constructor-super": "off",
"default-param-last": "off",
"getter-return": "off",
"import/no-unresolved": "off",
Expand All @@ -110,16 +112,26 @@
"no-dupe-keys": "off",
"no-empty-function": "off",
"no-extra-parens": "off",
"no-extra-semi": "off",
"no-func-assign": "off",
"no-import-assign": "off",
"no-magic-numbers": "off",
"no-new-symbol": "off",
"no-obj-calls": "off",
"no-redeclare": "off",
"no-setter-return": "off",
"no-this-before-super": "off",
"no-undef": "off",
"no-unreachable": "off",
"no-unsafe-negation": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-constructor": "off",
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"quotes": "off",
"valid-typeof": "off"
}
25 changes: 5 additions & 20 deletions packages/typescript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,12 @@ module.exports = {

plugins: ['@typescript-eslint'],

extends: ['plugin:@typescript-eslint/recommended'],

rules: {
// Checked by TypeScript - ts(2378)
'getter-return': 'off',
// Checked by TypeScript - ts(2300)
'no-dupe-args': 'off',
// Checked by TypeScript - ts(1117)
'no-dupe-keys': 'off',
// Checked by TypeScript - ts(7027)
'no-unreachable': 'off',
// Checked by TypeScript - ts(2367)
'valid-typeof': 'off',
// Checked by TypeScript - ts(2588)
'no-const-assign': 'off',
// Checked by TypeScript - ts(2588)
'no-new-symbol': 'off',
// Checked by TypeScript - ts(2376)
'no-this-before-super': 'off',
// Checked by TypeScript - `strictNullChecks`
'no-undef': 'off',
// Checked by TypeScript
'no-redeclare': 'off',
// Should be disabled per Prettier
'@typescript-eslint/no-extra-semi': 'off',

// Checked by TypeScript
'import/no-unresolved': 'off',

Expand Down
18 changes: 9 additions & 9 deletions scripts/validate-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ async function main() {
* Prettier violations.
*/
function logPrettierViolations(prettierViolations) {
console.error(
`\nError: Detected Prettier rule violations. Disable the specified rule(s) in the following package(s):\n\n${Object.entries(
prettierViolations,
)
.map(([packageName, rules]) => {
return `${tabs(1)}${packageName}\n${rules.join(`${tabs(2)}\n`)}`;
})
.join(`\n${tabs(1)}`)}`,
);
let str = `\nError: Detected Prettier rule violations. Disable the specified rule(s) in the following package(s):\n`;
Object.entries(prettierViolations).forEach(([packageName, violatedRules]) => {
if (prettierViolations[packageName].length > 0) {
str += `\n${tabs(1)}${packageName}\n${tabs(2)}${violatedRules.join(
`${tabs(2)}\n`,
)}\n`;
}
});
console.error(str);
}

/**
Expand Down

0 comments on commit 282ef52

Please sign in to comment.