Skip to content

Commit

Permalink
feat: add more plugins to config
Browse files Browse the repository at this point in the history
New configs contains node and unicorn and more configs of basic rules
  • Loading branch information
xobotyi committed Aug 14, 2023
1 parent 1021a0c commit edf4077
Show file tree
Hide file tree
Showing 9 changed files with 629 additions and 290 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
extends: ['./base.cjs'],
overrides: [
{
files: ['*.js', '*.cjs', '*.mjs'],
extends: ['./base.cjs'],
},
{
files: ['*.md'],
extends: ['./md.cjs'],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: "Lint"
run: yarn lint -f @react-hookz/gha
run: yarn lint -f @react-hookz/gha .

dependabot-merge:
name: "Dependabot automerge"
Expand Down
103 changes: 102 additions & 1 deletion base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,118 @@ module.exports = {
extends: [
'plugin:import/recommended',
'plugin:promise/recommended',
'plugin:unicorn/recommended',
'xo',
'plugin:prettier/recommended',
],
plugins: ['no-use-extend-native', 'unicorn', 'promise', 'import', 'eslint-comments'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'no-use-extend-native/no-use-extend-native': 'error',

'unicorn/better-regex': [
'error',
{
sortCharacterClasses: false,
},
],

// Disabled for now until it becomes more stable:
// https://github.com/sindresorhus/eslint-plugin-unicorn/search?q=consistent-destructuring+is:issue&state=open&type=issues
'unicorn/consistent-destructuring': 'off',

'unicorn/prefer-ternary': ['error', 'only-single-line'],

'function-call-argument-newline': 'off',

'import/default': 'error',
'import/export': 'error',
'import/extensions': [
'error',
'always',
{
ignorePackages: true,
},
],
'import/first': 'error',

'import/namespace': [
'error',
{
allowComputed: true,
},
],
'import/no-absolute-path': 'error',
'import/no-anonymous-default-export': 'error',
'import/no-named-default': 'error',
'import/no-webpack-loader-syntax': 'error',
'import/no-self-import': 'error',
'import/no-cycle': [
'error',
{
ignoreExternal: true,
},
],
'import/no-useless-path-segments': 'error',
'import/newline-after-import': 'error',
'import/no-amd': 'error',
'import/no-duplicates': [
'error',
{
'prefer-inline': true,
},
],
'import/no-empty-named-blocks': 'error',
'import/no-extraneous-dependencies': [
'error',
{
includeTypes: true,
},
],
'import/no-mutable-exports': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-as-default': 'error',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
'newlines-between': 'never',
warnOnUnassignedImports: true,
},
],
'import/no-unassigned-import': [
'error',
{
allow: [
'@babel/polyfill',
'**/register',
'**/register.*',
'**/register/**',
'**/register/**.*',
'**/*.css',
'**/*.scss',
'**/*.sass',
'**/*.less',
],
},
],

// Promise, if placed in the end of the chain may viable have no return statement.
// Promise, if placed in the end of the chain may viably have no return statement.
'promise/always-return': 'off',

'eslint-comments/disable-enable-pair': [
'error',
{
allowWholeFile: true,
},
],
'eslint-comments/no-aggregating-enable': 'error',
'eslint-comments/no-duplicate-disable': 'error',

'eslint-comments/no-unused-disable': 'error',
'eslint-comments/no-unused-enable': 'error',
},
};
2 changes: 1 addition & 1 deletion md.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
extends: ['plugin:mdx/recommended', 'plugin:prettier/recommended'],
rules: {
'prettier/prettier': ['error', {parser: 'markdown'}],
'prettier/prettier': ['error', { parser: 'markdown' }],
},
};
42 changes: 42 additions & 0 deletions node.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
extends: ['plugin:prettier/recommended'],
plugins: ['n'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
// We have this enabled in addition to `import/extensions` as this one has an auto-fix.
'n/file-extension-in-import': [
'error',
'always',
{
// TypeScript doesn't yet support using extensions and fails with error TS2691.
'.ts': 'never',
'.tsx': 'never',
'.mts': 'never',
'.cts': 'never',
},
],
'n/no-mixed-requires': [
'error',
{
grouping: true,
allowCall: true,
},
],
'n/no-new-require': 'error',
'n/no-path-concat': 'error',
'n/process-exit-as-throw': 'error',
'n/no-deprecated-api': 'error',
'n/prefer-global/buffer': ['error', 'never'],
'n/prefer-global/console': ['error', 'always'],
'n/prefer-global/process': ['error', 'never'],
'n/prefer-global/text-decoder': ['error', 'always'],
'n/prefer-global/text-encoder': ['error', 'always'],
'n/prefer-global/url-search-params': ['error', 'always'],
'n/prefer-global/url': ['error', 'always'],
'n/prefer-promises/dns': 'error',
'n/prefer-promises/fs': 'error',
},
};
44 changes: 24 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-hookz/eslint-config",
"version": "2.0.4",
"version": "2.0.3",
"description": "eslint configuration files used in @react-hookz projects",
"license": "MIT",
"repository": {
Expand All @@ -16,42 +16,46 @@
"type": "module",
"main": "./base.cjs",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"eslint": "8.47.0",
"eslint-config-prettier": "9.0.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-react": "^0.27.0",
"eslint-config-xo-typescript": "^0.57.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-mdx": "^2.2.0",
"eslint-config-xo-typescript": "1.0.1",
"eslint-import-resolver-typescript": "3.6.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "2.28.0",
"eslint-plugin-jest": "27.2.3",
"eslint-plugin-mdx": "2.2.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-no-use-extend-native": "^0.5.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react": "7.33.1",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.0.1"
"eslint-plugin-unicorn": "^48.0.1",
"prettier": "3.0.1"
},
"devDependencies": {
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.7.0",
"@commitlint/cz-commitlint": "^17.7.1",
"@commitlint/cli": "17.7.1",
"@commitlint/config-conventional": "17.7.0",
"@commitlint/cz-commitlint": "17.7.1",
"@react-hookz/eslint-formatter-gha": "^1.0.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.0.4",
"@semantic-release/github": "9.0.4",
"commitizen": "^4.3.0",
"commitlint": "^17.7.1",
"commitlint": "17.7.1",
"husky": "^8.0.3",
"lint-staged": "^14.0.0",
"lint-staged": "14.0.0",
"semantic-release": "^21.0.7",
"yarn": "^2.4.3"
"yarn": "^1.22.19"
},
"scripts": {
"prepare": "husky install",
"commit": "git-cz",
"lint": "eslint --ext .cjs,.js,.md",
"lint": "eslint",
"lint:fix": "yarn lint --fix"
},
"config": {
Expand Down
11 changes: 10 additions & 1 deletion react.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
module.exports = {
extends: ['xo-react', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
// While using ts with `react-jsx` preset - there
// is no need in importing react in each file
'react/react-in-jsx-scope': 'off',

// There is no sense in using prop-types with ts
// There is no sense in using prop-types within ts projects
'react/require-default-props': 'off',
'react/no-unused-prop-types': 'off',
'react/prop-types': 'off',
},
};
4 changes: 3 additions & 1 deletion typescript.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
{
selector: 'variable',
modifiers: ['destructured'],
// eslint-disable-next-line unicorn/no-null
format: null,
},
{
Expand All @@ -29,6 +30,7 @@ module.exports = {
'accessor',
'enumMember',
],
// eslint-disable-next-line unicorn/no-null
format: null,
modifiers: ['requiresQuotes'],
},
Expand All @@ -38,7 +40,7 @@ module.exports = {
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
],
// Deviation from xo's config - we allow susage of null and empty array types.
// Deviation from xo's config - we allow usage of null and empty array types.
'@typescript-eslint/ban-types': [
'error',
{
Expand Down
Loading

0 comments on commit edf4077

Please sign in to comment.