@mediatool/eslint-config-mediatool 0.2.1 → 1.0.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.
package/.eslintrc.js CHANGED
@@ -1,68 +1,147 @@
1
- module.exports = {
2
- extends: 'airbnb',
3
- plugins: [ 'mocha', 'react' ],
4
- rules: {
5
- 'array-bracket-spacing': [ 'error', 'always' ],
6
- 'arrow-parens': [ 'error', 'always' ],
7
- camelcase: [ 'error', {
8
- allow: [
9
- 'UNSAFE_componentWillMount',
10
- 'UNSAFE_componentWillReceiveProps',
11
- 'UNSAFE_componentWillUpdate',
12
- '^_mt_',
1
+ const javascriptRules = {
2
+ 'array-bracket-spacing': [ 'error', 'always' ],
3
+ 'arrow-parens': [ 'error', 'always' ],
4
+ camelcase: [ 'error', {
5
+ allow: [
6
+ 'UNSAFE_componentWillMount',
7
+ 'UNSAFE_componentWillReceiveProps',
8
+ 'UNSAFE_componentWillUpdate',
9
+ '^_mt_',
10
+ ],
11
+ ignoreDestructuring: true,
12
+ } ],
13
+ 'comma-dangle': [ 'error', {
14
+ arrays: 'always-multiline',
15
+ objects: 'always-multiline',
16
+ imports: 'always-multiline',
17
+ exports: 'always-multiline',
18
+ functions: 'never',
19
+ } ],
20
+ 'func-names': 0,
21
+ 'function-paren-newline': 'off',
22
+ 'global-require': 0,
23
+ 'import/extensions': 0,
24
+ 'import/no-extraneous-dependencies': [
25
+ 'error',
26
+ {
27
+ devDependencies: [
28
+ '**/demo/**/*.*',
29
+ '**/features/**/*.*',
30
+ '**/test/**/*.*',
31
+ '**/lib/**/*-test.*',
32
+ '**/lib/**/*-stories.*',
33
+ '**/rollup.config.js',
13
34
  ],
14
- ignoreDestructuring: true,
15
- } ],
16
- 'comma-dangle': [ 'error', {
35
+ },
36
+ ],
37
+ 'jsx-a11y/anchor-is-valid': 'off',
38
+ 'jsx-a11y/click-events-have-key-events': 'off', // Consider enabling later
39
+ 'jsx-a11y/interactive-supports-focus': 'off', // Consider enabling later
40
+ 'jsx-a11y/label-has-for': 'off',
41
+ 'jsx-a11y/no-autofocus': 'off',
42
+ 'jsx-a11y/no-noninteractive-element-interactions': 'off',
43
+ 'jsx-a11y/no-static-element-interactions': 'off', // Consider enabling later
44
+ 'no-multiple-empty-lines': [ 'warn', { max: 1, maxBOF: 0, maxEOF: 0 } ],
45
+ 'no-nested-ternary': 'off',
46
+ 'no-underscore-dangle': 0,
47
+ 'no-unused-vars': [ 'error', {
48
+ vars: 'all',
49
+ args: 'all',
50
+ argsIgnorePattern: '^_',
51
+ ignoreRestSiblings: false,
52
+ } ],
53
+ 'react/jsx-boolean-value': [ 'error', 'always' ],
54
+ 'react/jsx-curly-spacing': [ 2, { when: 'always', children: true } ],
55
+ 'react/no-multi-comp': 0,
56
+ 'react/no-unescaped-entities': 'off',
57
+ 'react/prefer-es6-class': 0,
58
+ 'react/prop-types': 0,
59
+ 'react/react-in-jsx-scope': 0,
60
+ semi: [ 'error', 'never' ],
61
+ 'sort-imports': [ 'warn', { ignoreDeclarationSort: true } ],
62
+ 'space-before-function-paren': [ 'error', 'always' ],
63
+ }
64
+
65
+ const typescriptRules = {
66
+ ...javascriptRules,
67
+ '@typescript-eslint/semi': [ 'error', 'never' ],
68
+ '@typescript-eslint/comma-dangle': [
69
+ 'error',
70
+ {
17
71
  arrays: 'always-multiline',
18
72
  objects: 'always-multiline',
19
73
  imports: 'always-multiline',
20
74
  exports: 'always-multiline',
21
75
  functions: 'never',
22
- } ],
23
- 'func-names': 0,
24
- 'function-paren-newline': 'off',
25
- 'global-require': 0,
26
- 'import/extensions': 0,
27
- 'import/no-extraneous-dependencies': [
28
- 'error',
29
- {
30
- devDependencies: [
31
- '**/demo/**/*.*',
32
- '**/features/**/*.*',
33
- '**/test/**/*.*',
34
- '**/rollup.config.js',
35
- ],
76
+ },
77
+ ],
78
+ 'import/prefer-default-export': 0,
79
+ '@typescript-eslint/space-before-function-paren': [ 'error', 'always' ],
80
+ '@typescript-eslint/no-use-before-define': [ 'error' ],
81
+ '@typescript-eslint/member-delimiter-style': [
82
+ 'error', {
83
+ multiline: {
84
+ delimiter: 'none',
36
85
  },
37
- ],
38
- 'jsx-a11y/anchor-is-valid': 'off',
39
- 'jsx-a11y/click-events-have-key-events': 'off', // Consider enabling later
40
- 'jsx-a11y/interactive-supports-focus': 'off', // Consider enabling later
41
- 'jsx-a11y/label-has-for': 'off',
42
- 'jsx-a11y/no-autofocus': 'off',
43
- 'jsx-a11y/no-noninteractive-element-interactions': 'off',
44
- 'jsx-a11y/no-static-element-interactions': 'off', // Consider enabling later
45
- 'no-multiple-empty-lines': [ 'warn', { max: 1, maxBOF: 0, maxEOF: 0 } ],
46
- 'no-nested-ternary': 'off',
47
- 'no-underscore-dangle': 0,
48
- 'no-unused-vars': [ 'error', {
49
- vars: 'all',
50
- args: 'all',
51
- argsIgnorePattern: '^_',
52
- ignoreRestSiblings: false,
86
+ singleline: {
87
+ delimiter: 'comma',
88
+ requireLast: false,
89
+ },
90
+ multilineDetection: 'brackets',
53
91
  } ],
54
- 'react/jsx-boolean-value': [ 'error', 'always' ],
55
- 'react/jsx-curly-spacing': [ 2, { when: 'always', children: true } ],
56
- 'react/no-multi-comp': 0,
57
- 'react/no-unescaped-entities': 'off',
58
- 'react/prefer-es6-class': 0,
59
- 'react/prop-types': 0,
60
- 'react/react-in-jsx-scope': 0,
61
- semi: [ 'error', 'never' ],
62
- 'sort-imports': [ 'warn', { ignoreDeclarationSort: true } ],
63
- 'space-before-function-paren': [ 'error', 'always' ],
64
- },
92
+ '@typescript-eslint/naming-convention': [
93
+ 'error',
94
+ {
95
+ selector: 'interface',
96
+ format: [ 'PascalCase' ],
97
+ custom: {
98
+ regex: '^I[A-Z]',
99
+ match: false,
100
+ },
101
+ },
102
+ ],
103
+ }
104
+
105
+ module.exports = {
65
106
  overrides: [
107
+ {
108
+ files: [ '*.js', '*.jsx' ],
109
+ extends: 'airbnb',
110
+ plugins: [ 'mocha', 'react' ],
111
+ rules: javascriptRules,
112
+ env: {
113
+ mocha: true,
114
+ browser: true,
115
+ },
116
+ parserOptions: {
117
+ ecmaVersion: 2021,
118
+ ecmaFeatures: {
119
+ jsx: true,
120
+ modules: true,
121
+ },
122
+ },
123
+ },
124
+ {
125
+ files: [ '*.ts', '*.tsx' ],
126
+ extends: [ 'airbnb', 'airbnb-typescript' ],
127
+ plugins: [ '@typescript-eslint' ],
128
+ parser: '@typescript-eslint/parser',
129
+ parserOptions: {
130
+ tsconfigRootDir: __dirname,
131
+ project: './tsconfig.json',
132
+ sourceType: 'module',
133
+ ecmaFeatures: {
134
+ jsx: true,
135
+ },
136
+ },
137
+ rules: typescriptRules,
138
+ },
139
+ {
140
+ files: [ '*-stories.*' ],
141
+ rules: {
142
+ 'no-console': 'off',
143
+ },
144
+ },
66
145
  {
67
146
  files: [ 'demo/*.*' ],
68
147
  rules: {
@@ -70,15 +149,4 @@ module.exports = {
70
149
  },
71
150
  },
72
151
  ],
73
- env: {
74
- mocha: true,
75
- browser: true,
76
- },
77
- parserOptions: {
78
- ecmaVersion: 2021,
79
- ecmaFeatures: {
80
- jsx: true,
81
- modules: true,
82
- },
83
- },
84
152
  }
@@ -0,0 +1,21 @@
1
+ function hello (_: any, x: string) {
2
+ return x
3
+ }
4
+
5
+ function factory (
6
+ a: number,
7
+ b: number,
8
+ c: number,
9
+ d: (a: object) => void
10
+ ) {
11
+ const obj = {
12
+ a,
13
+ b,
14
+ c,
15
+ _mt_entry_type: 'planning',
16
+ }
17
+ return d(obj)
18
+ }
19
+
20
+ factory(1, 2, 3, () => {})
21
+ hello(1, 'a')
@@ -0,0 +1,10 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import React, { useState } from 'react'
3
+
4
+ const ExampleComponent = () => {
5
+ const [ message ] = useState('Hey')
6
+
7
+ return <div>{ message }</div>
8
+ }
9
+
10
+ export default ExampleComponent
package/package.json CHANGED
@@ -1,17 +1,26 @@
1
1
  {
2
2
  "name": "@mediatool/eslint-config-mediatool",
3
- "version": "0.2.1",
3
+ "version": "1.0.0",
4
4
  "main": ".eslintrc.js",
5
5
  "scripts": {
6
6
  "pretest": "yarn",
7
- "test": "eslint demo/*.* examples/*.* --max-warnings 0"
7
+ "lint": "eslint demo/*.* examples/*.* --max-warnings 0",
8
+ "test": "yarn lint"
8
9
  },
9
10
  "dependencies": {
11
+ "@typescript-eslint/eslint-plugin": "^4.32.0",
12
+ "@typescript-eslint/parser": "^4.32.0",
10
13
  "eslint": "^7.8.1",
11
14
  "eslint-config-airbnb": "^16.1.0",
15
+ "eslint-config-airbnb-typescript": "^14.0.0",
12
16
  "eslint-plugin-import": "^2.18.2",
13
17
  "eslint-plugin-jsx-a11y": "^6.2.3",
14
18
  "eslint-plugin-mocha": "^6.1.0",
15
- "eslint-plugin-react": "^7.14.3"
19
+ "eslint-plugin-react": "^7.14.3",
20
+ "typescript": "^4.4.3"
21
+ },
22
+ "devDependencies": {
23
+ "@types/react": "^17.0.24",
24
+ "react": "^17.0.2"
16
25
  }
17
26
  }
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "noFallthroughCasesInSwitch": true,
5
+ "noUnusedParameters": true,
6
+ "noImplicitReturns": true,
7
+ "moduleResolution": "node",
8
+ "esModuleInterop": true,
9
+ "noUnusedLocals": true,
10
+ "noImplicitAny": true,
11
+ "declarationDir": "dist/types",
12
+ "declaration": true,
13
+ "target": "esnext",
14
+ "module": "esnext",
15
+ "strict": true,
16
+ "jsx": "react",
17
+ "typeRoots": [ "types" ],
18
+ "types": [ "mocha", "chai-spies" ],
19
+ "paths": {
20
+ "@lib/*": [ "./lib/*" ]
21
+ }
22
+ },
23
+ "include": [
24
+ "**/*",
25
+ ],
26
+ "exclude": [
27
+ "node_modules",
28
+ "dist",
29
+ ]
30
+ }