@shelf/eslint-config 1.9.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ #!/bin/sh
2
+ if [ -z "$husky_skip_init" ]; then
3
+ debug () {
4
+ if [ "$HUSKY_DEBUG" = "1" ]; then
5
+ echo "husky (debug) - $1"
6
+ fi
7
+ }
8
+
9
+ readonly hook_name="$(basename "$0")"
10
+ debug "starting $hook_name..."
11
+
12
+ if [ "$HUSKY" = "0" ]; then
13
+ debug "HUSKY env variable is set to 0, skipping hook"
14
+ exit 0
15
+ fi
16
+
17
+ if [ -f ~/.huskyrc ]; then
18
+ debug "sourcing ~/.huskyrc"
19
+ . ~/.huskyrc
20
+ fi
21
+
22
+ export readonly husky_skip_init=1
23
+ sh -e "$0" "$@"
24
+ exitCode="$?"
25
+
26
+ if [ $exitCode != 0 ]; then
27
+ echo "husky - $hook_name hook exited with code $exitCode (error)"
28
+ fi
29
+
30
+ exit $exitCode
31
+ fi
package/CHANGELOG.md CHANGED
@@ -1,2 +1,8 @@
1
+ ## 2.0.0
2
+
3
+ Removed separate file for testing-library, added testing-library rules to `frontend-typescript.js`.
4
+ Extended `frontend.js` in `frontend-typescript.js` and `frontend-typescript-vue.js`.
5
+
1
6
  ## 1.0.0
7
+
2
8
  Breaking changes of the eslint-config-prettier 8.0.0
@@ -1,34 +1,24 @@
1
- const importOrder = require('./rules/import-order.json');
2
- const sortImports = require('./rules/sort-imports.json');
3
1
  const {allowRequireInConfigs, noExplicitReturnTypeInTests} = require('./rules/overrides');
4
2
  const consistentTypeAssertions = require('./rules/consistent-type-assertions.json');
3
+ const vueConfig = require('./frontend-vue');
5
4
 
6
5
  module.exports = {
7
6
  extends: [
8
- '@shelf/eslint-config',
7
+ './frontend-vue',
9
8
  'plugin:@typescript-eslint/eslint-recommended',
10
9
  'plugin:@typescript-eslint/recommended',
11
- 'plugin:prettier/recommended',
12
- 'plugin:vue/essential',
13
10
  ],
14
- plugins: ['@typescript-eslint', 'vue', 'babel', 'jsx', 'import'],
15
- env: {
16
- browser: true,
17
- },
11
+ plugins: ['@typescript-eslint', ...vueConfig.plugins],
18
12
  parserOptions: {
13
+ ...vueConfig.parserOptions,
19
14
  parser: '@typescript-eslint/parser',
20
- ecmaFeatures: {
21
- jsx: true,
22
- },
23
15
  },
24
16
  rules: {
25
- ...importOrder,
26
- ...sortImports,
17
+ ...vueConfig.rules,
27
18
  '@typescript-eslint/no-use-before-define': 0,
28
19
  '@typescript-eslint/camelcase': 0,
29
20
  '@typescript-eslint/explicit-member-accessibility': 0,
30
21
  'jest/lowercase-name': 'off',
31
- 'comma-dangle': 'off',
32
22
  ...consistentTypeAssertions,
33
23
  },
34
24
  overrides: [allowRequireInConfigs, noExplicitReturnTypeInTests],
@@ -1,28 +1,19 @@
1
1
  const commonExtends = require('./rules/extends-common.json');
2
2
  const commonPlugins = require('./common/plugins');
3
- const env = require('./common/env');
4
- const importOrder = require('./rules/import-order.json');
5
- const jestRules = require('./rules/jest.json');
6
- const paddingLineBetweenStatements = require('./rules/padding-line-between-statements');
7
- const preferDestructuring = require('./rules/prefer-destructuring');
8
- const sortImports = require('./rules/sort-imports.json');
9
3
  const tsParser = require('./common/ts-parser');
10
4
  const {allowRequireInConfigs, noExplicitReturnTypeInTests} = require('./rules/overrides');
11
5
  const consistentTypeAssertions = require('./rules/consistent-type-assertions.json');
6
+ const frontendConfig = require('./frontend');
12
7
 
13
8
  module.exports = {
14
- extends: [...commonExtends, 'plugin:react/recommended', 'plugin:react-hooks/recommended'],
9
+ extends: ['./frontend.js', ...commonExtends],
15
10
  globals: {
16
11
  DD_LOGS: true,
17
12
  },
18
- plugins: [...commonPlugins, 'react'],
19
- env: {
20
- ...env,
21
- browser: true,
22
- },
13
+ plugins: [...commonPlugins, ...frontendConfig.plugins, 'testing-library'],
23
14
  ...tsParser,
24
15
  rules: {
25
- 'prettier/prettier': 'error',
16
+ ...frontendConfig.rules,
26
17
  '@typescript-eslint/no-use-before-define': 0,
27
18
  '@typescript-eslint/camelcase': 0,
28
19
  // it fail to compile TS on react static class properties (displayName | defaultProps | etc..)
@@ -33,17 +24,24 @@ module.exports = {
33
24
  '@typescript-eslint/no-empty-function': 'off',
34
25
  'react/prop-types': 'off',
35
26
  'react/display-name': 'warn',
36
- 'padding-line-between-statements': paddingLineBetweenStatements,
37
- ...jestRules,
38
- ...preferDestructuring,
39
- 'prefer-template': 'error',
40
- 'prefer-object-spread': 'error',
41
- ...importOrder,
42
- ...sortImports,
43
27
  '@typescript-eslint/no-unused-vars': 'error',
44
- 'comma-dangle': 'off',
45
- 'no-console': 'error',
46
28
  ...consistentTypeAssertions,
29
+ 'testing-library/await-async-query': 'error',
30
+ 'testing-library/no-await-sync-query': 'error',
31
+ 'testing-library/no-debug': 'warn',
32
+ 'testing-library/consistent-data-testid': [
33
+ 2,
34
+ {
35
+ testIdPattern: '^(([a-z])+(-)*)+$',
36
+ },
37
+ ],
47
38
  },
48
- overrides: [allowRequireInConfigs, noExplicitReturnTypeInTests],
39
+ overrides: [
40
+ allowRequireInConfigs,
41
+ noExplicitReturnTypeInTests,
42
+ {
43
+ files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
44
+ extends: ['plugin:testing-library/react'],
45
+ },
46
+ ],
49
47
  };
package/frontend-vue.js CHANGED
@@ -1,7 +1,5 @@
1
- const importOrder = require('./rules/import-order.json');
2
-
3
1
  module.exports = {
4
- extends: ['@shelf/eslint-config', 'plugin:prettier/recommended', 'plugin:vue/essential'],
2
+ extends: ['./base.js', 'plugin:vue/essential'],
5
3
  plugins: ['vue', 'babel', 'jsx', 'import'],
6
4
  env: {
7
5
  browser: true,
@@ -12,8 +10,4 @@ module.exports = {
12
10
  jsx: true,
13
11
  },
14
12
  },
15
- rules: {
16
- ...importOrder,
17
- 'comma-dangle': 'off',
18
- },
19
13
  };
package/frontend.js CHANGED
@@ -1,13 +1,8 @@
1
- const importOrder = require('./rules/import-order.json');
2
1
  const env = require('./common/env');
2
+ const baseConfig = require('./base');
3
3
 
4
4
  module.exports = {
5
- extends: [
6
- '@shelf/eslint-config',
7
- 'plugin:react/recommended',
8
- 'prettier',
9
- 'plugin:react-hooks/recommended',
10
- ],
5
+ extends: ['./base.js', 'plugin:react/recommended', 'prettier', 'plugin:react-hooks/recommended'],
11
6
  plugins: ['react', 'import'],
12
7
  env: {
13
8
  browser: true,
@@ -20,8 +15,7 @@ module.exports = {
20
15
  },
21
16
  },
22
17
  rules: {
23
- ...importOrder,
24
- 'comma-dangle': 'off',
18
+ ...baseConfig.rules,
25
19
  'no-console': 'error',
26
20
  },
27
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shelf/eslint-config",
3
- "version": "1.9.0",
3
+ "version": "2.3.0",
4
4
  "description": "ESLint Config for Shelf Projects",
5
5
  "license": "MIT",
6
6
  "repository": "shelfio/eslint-config",
@@ -23,7 +23,6 @@
23
23
  "frontend-vue.js",
24
24
  "frontend-typescript.js",
25
25
  "frontend-typescript-vue.js",
26
- "frontend-testing-library.js",
27
26
  "meteor.js",
28
27
  "typescript.js"
29
28
  ],
@@ -33,37 +32,32 @@
33
32
  "eslintconfig"
34
33
  ],
35
34
  "dependencies": {
36
- "@babel/eslint-parser": "7.15.0",
37
- "@typescript-eslint/eslint-plugin": "4.31.0",
38
- "@typescript-eslint/parser": "4.31.0",
35
+ "@babel/eslint-parser": "7.15.8",
36
+ "@typescript-eslint/eslint-plugin": "4.33.0",
37
+ "@typescript-eslint/parser": "4.33.0",
39
38
  "eslint-config-next": "11.1.2",
40
39
  "eslint-config-prettier": "8.3.0",
41
40
  "eslint-plugin-babel": "5.3.1",
42
- "eslint-plugin-import": "2.24.2",
41
+ "eslint-plugin-import": "2.25.2",
43
42
  "eslint-plugin-jest": "24.4.3",
44
43
  "eslint-plugin-jest-formatting": "3.0.0",
45
44
  "eslint-plugin-json-format": "2.0.1",
46
45
  "eslint-plugin-jsx": "0.1.0",
47
46
  "eslint-plugin-prettier": "3.4.1",
48
- "eslint-plugin-react": "7.24.0",
47
+ "eslint-plugin-react": "7.26.1",
49
48
  "eslint-plugin-react-hooks": "4.2.0",
50
- "eslint-plugin-testing-library": "4.12.0",
51
- "eslint-plugin-vue": "7.14.0"
49
+ "eslint-plugin-testing-library": "4.12.4",
50
+ "eslint-plugin-vue": "7.19.1"
52
51
  },
53
52
  "devDependencies": {
54
- "husky": "4.3.8",
55
- "lint-staged": "11.1.2",
56
- "prettier": "2.4.0"
53
+ "husky": "7.0.2",
54
+ "lint-staged": "11.2.3",
55
+ "prettier": "2.4.1"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "eslint": "7.x",
60
59
  "prettier": "2.x"
61
60
  },
62
- "husky": {
63
- "hooks": {
64
- "pre-commit": "lint-staged"
65
- }
66
- },
67
61
  "lint-staged": {
68
62
  "*.{js,json,css,md,yml}": [
69
63
  "prettier --write",
package/typescript.js CHANGED
@@ -16,7 +16,10 @@ module.exports = {
16
16
  env,
17
17
  ...tsParser,
18
18
  rules: {
19
- complexity: ['warn', {max: 6}],
19
+ complexity: ['warn', {max: 5}],
20
+ 'multiline-ternary': ['error', 'never'],
21
+ curly: 'error',
22
+ 'no-nested-ternary': 'error',
20
23
  'prettier/prettier': 'error',
21
24
  '@typescript-eslint/no-use-before-define': 0,
22
25
  '@typescript-eslint/camelcase': 0,
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- plugins: ['testing-library'],
3
- rules: {
4
- 'testing-library/await-async-query': 'error',
5
- 'testing-library/no-await-sync-query': 'error',
6
- 'testing-library/no-debug': 'warn',
7
- 'testing-library/consistent-data-testid': [
8
- 2,
9
- {
10
- testIdPattern: '^(([a-z])+(-)*)+$',
11
- },
12
- ],
13
- },
14
- overrides: [
15
- {
16
- files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
17
- extends: ['plugin:testing-library/react'],
18
- },
19
- ],
20
- };