Skip to content

Add test config #2

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

Merged
merged 3 commits into from
Jun 26, 2024
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
78 changes: 6 additions & 72 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,80 +4,14 @@ module.exports = {
es6: true,
node: false
},
extends: ["airbnb"],
extends: [
"airbnb"
].concat([
"./rules/default"
].map(require.resolve)),
parser: "@babel/eslint-parser",
plugins: ["@babel"],
rules: {
"@babel/object-curly-spacing": "error", // Replace non-babel version
"arrow-parens": ["error", "always"], // Consistency
"class-methods-use-this": "off", // Allows methods to be overridden
"comma-dangle": ["error", "never"], // Unnecessary
"consistent-return": "off", // Makes it hard to return early for conditionals
"func-names": "off", // Unnecessary and unused with arrow functions
"jsx-a11y/label-has-for": ["error", {
components: [],
required: {
some: ["nesting", "id"],
},
allowChildren: false,
}], // Unnecessary to have nesting for both
"keyword-spacing": ["error", {
after: false,
before: false,
overrides: {
as: {before: true, after: true},
case: {before: true, after: true},
catch: {before: true, after: false},
const: {before: true, after: true},
default: {before: true, after: true},
else: {before: true, after: true},
export: {before: true, after: true},
from: {before: true, after: true},
import: {before: true, after: true},
let: {before: true, after: true},
return: {before: true, after: true},
this: {before: true, after: true},
try: {before: true, after: true}
}
}], // Whitespace - Preference
"lines-between-class-members": ["error", "never"],
"no-else-return": "off", // Allows more functional styles
"no-lonely-if": "off", // Allows more readable conditions
"no-multiple-empty-lines": ["error", {max: 1, maxBOF: 0, maxEOF: 0}], // Little stricter
"no-promise-executor-return": "off", // Makes it hard to return early for conditions
"no-underscore-dangle": "off", // Doesn't allow `const key = _key.toLowerCase()`
"no-unused-expressions": ["error", {allowShortCircuit: true, allowTernary: true}],
"object-curly-newline": ["error", {multiline: true, consistent: true}],
"object-curly-spacing": "off", // Incompatible with babel/object-curly-spacing
"prefer-destructuring": ["error", {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: false,
object: false,
},
}, {
enforceForRenamedProperties: false,
}], // Assignment expression looks funky with parens
"quote-props": ["error", "consistent-as-needed", {keywords: false}],
"quotes": ["error", "double", {allowTemplateLiterals: true}],
"react/destructuring-assignment": "off", // Overactive and solved by prefer-destructuring
"react/function-component-definition": ["error", {
namedComponents: ["function-declaration", "function-expression"],
unnamedComponents: "arrow-function"
}], // Allows simple arrow components
"react/jsx-boolean-value": ["error", "always"], // Prefer explicit
"react/jsx-filename-extension": "off", // Unnecessary
"react/jsx-one-expression-per-line": "off", // Creates unnecessary white space issues
"react/jsx-props-no-spreading": "off", // Unnecessary
"react/no-did-update-set-state": "off", // Makes hacks needed for prop change triggers
"react/prefer-stateless-function": "off", // Prefer React
"react/react-in-jsx-scope": "off", // Global React
"react/static-property-placement": ["error", "static public field"], // Airbnb will catch up
"space-before-function-paren": ["error", "never"] // Whitespace - Preference
},
rules: {},
settings: {
"import/resolver": "webpack",
react: {version: "detect"}
Expand Down
29 changes: 29 additions & 0 deletions jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
extends: [
"airbnb",
"plugin:jest/recommended"
].concat([
"./rules/default",
"./rules/jest"
].map(require.resolve)),
overrides: [
{
files: "*.config.js",
rules: {
"global-require": "off"
}
}
],
parser: "@babel/eslint-parser",
plugins: ["@babel"],
rules: {},
settings: {
"import/resolver": "webpack",
react: {version: "detect"}
}
};
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"eslint-import-resolver-webpack": "0.x"
},
"description": "Traitify's base ESLint config",
"files": [
"index.js",
"package.json",
"README.md"
],
"exports": {
".": "./index.js",
"./jest": "./jest.js",
"./package.json": "./package.json"
},
"homepage": "https://github.com/traitify/eslint-config-traitify#readme",
"keywords": [
"config",
Expand All @@ -28,7 +28,13 @@
"name": "eslint-config-traitify",
"peerDependencies": {
"@babel/eslint-plugin": "7.x",
"eslint": "8.x"
"eslint": "8.x",
"eslint-import-resolver-jest": ">=3",
"eslint-plugin-jest": ">=27"
},
"peerDependenciesMeta": {
"eslint-import-resolver-jest": {"optional": true},
"eslint-plugin-jest": {"optional": true}
},
"repository": {
"type": "git",
Expand All @@ -37,5 +43,5 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "0.3.0"
"version": "0.4.0"
}
74 changes: 74 additions & 0 deletions rules/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module.exports = {
rules: {
"@babel/object-curly-spacing": "error", // Replace non-babel version
"arrow-parens": ["error", "always"], // Consistency
"class-methods-use-this": "off", // Allows methods to be overridden
"comma-dangle": ["error", "never"], // Unnecessary
"consistent-return": "off", // Makes it hard to return early for conditionals
"func-names": "off", // Unnecessary and unused with arrow functions
"jsx-a11y/label-has-for": ["error", {
components: [],
required: {
some: ["nesting", "id"],
},
allowChildren: false,
}], // Unnecessary to have nesting for both
"keyword-spacing": ["error", {
after: false,
before: false,
overrides: {
as: {before: true, after: true},
case: {before: true, after: true},
catch: {before: true, after: false},
const: {before: true, after: true},
default: {before: true, after: true},
else: {before: true, after: true},
export: {before: true, after: true},
from: {before: true, after: true},
import: {before: true, after: true},
let: {before: true, after: true},
return: {before: true, after: true},
this: {before: true, after: true},
try: {before: true, after: true}
}
}], // Whitespace - Preference
"lines-between-class-members": ["error", "never"],
"no-else-return": "off", // Allows more functional styles
"no-lonely-if": "off", // Allows more readable conditions
"no-multiple-empty-lines": ["error", {max: 1, maxBOF: 0, maxEOF: 0}], // Little stricter
"no-promise-executor-return": "off", // Makes it hard to return early for conditions
"no-underscore-dangle": "off", // Doesn't allow `const key = _key.toLowerCase()`
"no-unused-expressions": ["error", {allowShortCircuit: true, allowTernary: true}],
"object-curly-newline": ["error", {multiline: true, consistent: true}],
"object-curly-spacing": "off", // Incompatible with babel/object-curly-spacing
"prefer-destructuring": ["error", {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: false,
object: false,
},
}, {
enforceForRenamedProperties: false,
}], // Assignment expression looks funky with parens
"quote-props": ["error", "consistent-as-needed", {keywords: false}],
"quotes": ["error", "double", {allowTemplateLiterals: true}],
"react/destructuring-assignment": "off", // Overactive and solved by prefer-destructuring
"react/function-component-definition": ["error", {
namedComponents: ["function-declaration", "function-expression"],
unnamedComponents: "arrow-function"
}], // Allows simple arrow components
"react/jsx-boolean-value": ["error", "always"], // Prefer explicit
"react/jsx-filename-extension": "off", // Unnecessary
"react/jsx-one-expression-per-line": "off", // Creates unnecessary white space issues
"react/jsx-props-no-spreading": "off", // Unnecessary
"react/no-did-update-set-state": "off", // Makes hacks needed for prop change triggers
"react/prefer-stateless-function": "off", // Prefer React
"react/react-in-jsx-scope": "off", // Global React
"react/require-default-props": ["error", {functions: "defaultArguments"}], // Updated for React 18+
"react/static-property-placement": ["error", "static public field"], // Airbnb will catch up
"space-before-function-paren": ["error", "never"] // Whitespace - Preference
}
};
8 changes: 8 additions & 0 deletions rules/jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
rules: {
"import/no-unresolved": "off", // Enable when jest import/resolver is fixed
"no-new": "off", // Tests are exempt
"prefer-promise-reject-errors": "off", // Tests are exempt
"react/prop-types": "off" // Tests are exempt
}
};