Skip to content

Commit

Permalink
updated rules (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
nowyDEV authored Dec 19, 2022
1 parent 85008aa commit 3aae185
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
11 changes: 7 additions & 4 deletions mixins/graphql/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ module.exports = {
* @see https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/require-description.md
*/
"@graphql-eslint/require-description": [
"error",
{ types: true, DirectiveDefinition: true },
"warn",
{ types: false, DirectiveDefinition: true },
],

/**
Expand All @@ -125,11 +125,14 @@ module.exports = {
* @see https://github.com/B2o5T/graphql-eslint/blob/master/docs/rules/strict-id-in-types.md
*/
"@graphql-eslint/strict-id-in-types": [
"error",
"warn",
{
acceptedIdNames: ["id", "nid"],
acceptedIdTypes: ["ID"],
exceptions: { suffixes: ["Payload", "Response", "Data"] },
exceptions: {
types: ["Error"],
suffixes: ["Payload", "Response", "Data", "Error"],
},
},
],

Expand Down
3 changes: 2 additions & 1 deletion mixins/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ module.exports = {
/**
* Keep naming consistent.
* @see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
* DISABLED - not suitable for every case (like setState methods)
*/
"react/jsx-handler-names": [
"warn",
"off",
{
eventHandlerPrefix: "handle",
eventHandlerPropPrefix: "on",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nordcloud/eslint-config-pat",
"version": "4.7.4",
"version": "4.8.0",
"description": "Shareable ESLint config for PAT projects",
"author": "Nordcloud Engineering",
"license": "MIT",
Expand Down
37 changes: 25 additions & 12 deletions profile/_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ function buildRules(profile) {
/**
* If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.
* @see https://eslint.org/docs/latest/rules/no-else-return
* DISABLED - adding `else` can improve readability in some cases (e.g. huge blocks of code)
*/
"no-else-return": "error",
"no-else-return": "off",

/**
* JavaScript’s eval() function is potentially dangerous and is often misused.
Expand Down Expand Up @@ -272,12 +273,6 @@ function buildRules(profile) {
*/
"no-multi-assign": "error",

/**
* Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead.
* @see https://eslint.org/docs/latest/rules/no-negated-condition
*/
"no-negated-condition": "warn",

/**
* As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used.
* Unicode escape sequences should be used instead.
Expand Down Expand Up @@ -480,14 +475,25 @@ function buildRules(profile) {
// Ignore destructured names
{
selector: "variable",
types: ["array", "boolean", "function", "number", "string"],
modifiers: ["destructured"],
format: null,
},
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: ["is", "are", "should", "has", "can", "did", "will"],
prefix: [
"is",
"are",
"should",
"has",
"can",
"did",
"will",
"show",
"hide",
],
},
{
selector: "variable",
Expand Down Expand Up @@ -518,7 +524,7 @@ function buildRules(profile) {
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
leadingUnderscore: "allowDouble",
filter: {
regex: "^(&:)",
regex: "^(&:)|^[0-9]+$",
match: false,
},
},
Expand Down Expand Up @@ -815,7 +821,12 @@ function buildRules(profile) {
* WARNING: This rule hurts lint process performance
* @see https://typescript-eslint.io/rules/no-misused-promises
*/
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false,
},
],

// ====================================================================================================
// eslint-plugin-unicorn
Expand Down Expand Up @@ -963,9 +974,10 @@ function buildRules(profile) {
/**
* Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition.
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-condition.md
* DISABLED - reports logical operators like != or !== that are useful
*/
"no-negated-condition": "off",
"unicorn/no-negated-condition": "warn",
"unicorn/no-negated-condition": "off",

/**
* Keep code simple, improve readability.
Expand Down Expand Up @@ -1327,7 +1339,7 @@ function buildRules(profile) {
* Using an if-else statement typically results in more lines of code than a single-line ternary expression, which leads to an unnecessarily larger codebase that is more difficult to maintain.
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-ternary.md
*/
"unicorn/prefer-ternary": "error",
"unicorn/prefer-ternary": ["error", "only-single-line"],

/**
* This rule enforces you to throw a TypeError after a type checking if-statement, instead of a generic Error.
Expand Down Expand Up @@ -1359,6 +1371,7 @@ function buildRules(profile) {
envs: true,
Envs: true,
err: true,
Fn: true,
num: true,
Num: true,
org: true,
Expand Down

0 comments on commit 3aae185

Please sign in to comment.