@typeform/eslint-config 3.0.2 → 6.0.2
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/.eslintignore +1 -0
- package/.eslintrc +3 -0
- package/.github/pull_request_template.md +12 -0
- package/.github/workflows/ci-standard-checks.yml +24 -0
- package/.github/workflows/deploy.yml +48 -0
- package/.github/workflows/tests.yml +28 -0
- package/index.js +25 -13
- package/index.test.js +85 -0
- package/jest.config.js +1 -0
- package/package.json +29 -26
- package/test-cases/error-no-debugger.js +4 -0
- package/test-cases/pass.js +8 -0
- package/test-cases/warn-curly.js +7 -0
- package/test-cases/warn-no-console.js +4 -0
- package/test-cases/warn-no-var.js +3 -0
- package/test-cases/warn-prefer-destructuring.js +4 -0
- package/.travis.yml +0 -18
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/test-cases/**
|
package/.eslintrc
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI Standard Checks
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
types: [opened, edited, synchronize, reopened]
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
ci-standard-checks:
|
|
13
|
+
runs-on: [ubuntu-latest]
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Check Out Source Code
|
|
17
|
+
uses: actions/checkout@v2
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
|
|
21
|
+
- name: CI Standard Checks
|
|
22
|
+
uses: Typeform/ci-standard-checks@v1
|
|
23
|
+
with:
|
|
24
|
+
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Deploy
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- next
|
|
8
|
+
- alpha
|
|
9
|
+
- beta
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
main:
|
|
13
|
+
name: Run checks and deploy
|
|
14
|
+
runs-on: [ubuntu-latest]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Check out Git repository
|
|
18
|
+
uses: actions/checkout@v2
|
|
19
|
+
|
|
20
|
+
- name: Set up Node.js
|
|
21
|
+
uses: actions/setup-node@v1
|
|
22
|
+
with:
|
|
23
|
+
node-version: 14
|
|
24
|
+
|
|
25
|
+
- name: Set GitHub packages registry
|
|
26
|
+
run: |
|
|
27
|
+
npm config set '//npm.pkg.github.com/:_authToken' ${{ secrets.GH_TOKEN }}
|
|
28
|
+
npm config set @typeform:registry https://npm.pkg.github.com/
|
|
29
|
+
|
|
30
|
+
- name: Get yarn cache
|
|
31
|
+
uses: actions/cache@v2
|
|
32
|
+
id: yarn-cache
|
|
33
|
+
with:
|
|
34
|
+
path: node_modules
|
|
35
|
+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/**.yml') }}
|
|
36
|
+
|
|
37
|
+
- name: Install Node.js dependencies
|
|
38
|
+
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
|
39
|
+
run: yarn install --frozen-lockfile
|
|
40
|
+
|
|
41
|
+
- name: Run linting
|
|
42
|
+
run: yarn lint
|
|
43
|
+
|
|
44
|
+
- name: Release main
|
|
45
|
+
run: yarn semantic-release
|
|
46
|
+
env:
|
|
47
|
+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
48
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
types: [opened, reopened, synchronize, ready_for_review]
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
tests:
|
|
13
|
+
runs-on: [ubuntu-latest]
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Check Out Source Code
|
|
17
|
+
uses: actions/checkout@v2
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
|
|
21
|
+
- name: Set up
|
|
22
|
+
run: yarn
|
|
23
|
+
|
|
24
|
+
- name: Lint
|
|
25
|
+
run: yarn lint
|
|
26
|
+
|
|
27
|
+
- name: Test
|
|
28
|
+
run: yarn test
|
package/index.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
'react-app',
|
|
4
|
-
'plugin:jsx-a11y/recommended',
|
|
5
|
-
'prettier',
|
|
6
|
-
'prettier/@typescript-eslint',
|
|
7
|
-
'prettier/babel',
|
|
8
|
-
'prettier/react',
|
|
9
|
-
],
|
|
2
|
+
extends: ['react-app', 'plugin:jsx-a11y/recommended', 'prettier'],
|
|
10
3
|
plugins: ['jest'],
|
|
11
4
|
env: {
|
|
12
|
-
browser: true,
|
|
13
|
-
commonjs: true,
|
|
14
|
-
es6: true,
|
|
15
|
-
jest: true,
|
|
16
|
-
node: true,
|
|
5
|
+
'browser': true,
|
|
6
|
+
'commonjs': true,
|
|
7
|
+
'es6': true,
|
|
8
|
+
'jest': true,
|
|
9
|
+
'node': true,
|
|
17
10
|
'jest/globals': true,
|
|
18
11
|
},
|
|
19
12
|
parserOptions: {
|
|
@@ -22,6 +15,10 @@ module.exports = {
|
|
|
22
15
|
},
|
|
23
16
|
},
|
|
24
17
|
rules: {
|
|
18
|
+
'no-var': 'warn',
|
|
19
|
+
'curly': 'warn',
|
|
20
|
+
'prefer-destructuring': 'warn',
|
|
21
|
+
'@typescript-eslint/no-extra-semi': 'off',
|
|
25
22
|
'import/order': [
|
|
26
23
|
'warn',
|
|
27
24
|
{
|
|
@@ -31,9 +28,24 @@ module.exports = {
|
|
|
31
28
|
'import/export': 'warn',
|
|
32
29
|
'jest/no-focused-tests': 'error',
|
|
33
30
|
'no-console': 'warn',
|
|
31
|
+
'no-debugger': 'error',
|
|
34
32
|
'prefer-template': 'warn',
|
|
35
33
|
'react/prop-types': 'error',
|
|
36
34
|
'react-hooks/exhaustive-deps': 'error',
|
|
35
|
+
'react/jsx-key': ['warn', { checkFragmentShorthand: true }],
|
|
36
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
37
|
+
'no-restricted-imports': [
|
|
38
|
+
'warn',
|
|
39
|
+
{
|
|
40
|
+
patterns: [
|
|
41
|
+
{
|
|
42
|
+
group: ['@typeform/kitt/lib/*'],
|
|
43
|
+
message:
|
|
44
|
+
"🙈 The lib notation is deprecated. Refer to the Kitt's doc, and ping the FEAR team if you have a doubt",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
37
49
|
},
|
|
38
50
|
settings: {
|
|
39
51
|
react: {
|
package/index.test.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const child_process = require('child_process')
|
|
2
|
+
|
|
3
|
+
describe('eslint config', () => {
|
|
4
|
+
// #region Pass
|
|
5
|
+
it('should pass if there are no errors', () => {
|
|
6
|
+
const output = child_process
|
|
7
|
+
.execSync('yarn eslint -f "json" --no-ignore test-cases/pass.js')
|
|
8
|
+
.toString()
|
|
9
|
+
expect(output.includes('"errorCount":0')).toBeTruthy()
|
|
10
|
+
expect(output.includes('"fatalErrorCount":0')).toBeTruthy()
|
|
11
|
+
expect(output.includes('"warningCount":0')).toBeTruthy()
|
|
12
|
+
expect(output.includes('"fixableErrorCount":0')).toBeTruthy()
|
|
13
|
+
expect(output.includes('"fixableWarningCount":0')).toBeTruthy()
|
|
14
|
+
})
|
|
15
|
+
// #endregion
|
|
16
|
+
|
|
17
|
+
// #region Warn
|
|
18
|
+
it('should warn if console is used', () => {
|
|
19
|
+
const output = child_process
|
|
20
|
+
.execSync(
|
|
21
|
+
'yarn eslint -f "json" --no-ignore test-cases/warn-no-console.js'
|
|
22
|
+
)
|
|
23
|
+
.toString()
|
|
24
|
+
|
|
25
|
+
expect(output.includes('"ruleId":"no-console"')).toBeTruthy()
|
|
26
|
+
expect(output.includes('"errorCount":0')).toBeTruthy()
|
|
27
|
+
expect(output.includes('"warningCount":1')).toBeTruthy()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should warn if var is used', () => {
|
|
31
|
+
const output = child_process
|
|
32
|
+
.execSync('yarn eslint -f "json" --no-ignore test-cases/warn-no-var.js')
|
|
33
|
+
.toString()
|
|
34
|
+
|
|
35
|
+
expect(output.includes('"ruleId":"no-var"')).toBeTruthy()
|
|
36
|
+
expect(output.includes('"errorCount":0')).toBeTruthy()
|
|
37
|
+
expect(output.includes('"warningCount":1')).toBeTruthy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should warn if braces are not used', () => {
|
|
41
|
+
const output = child_process
|
|
42
|
+
.execSync('yarn eslint -f "json" --no-ignore test-cases/warn-curly.js')
|
|
43
|
+
.toString()
|
|
44
|
+
|
|
45
|
+
expect(output.includes('"ruleId":"curly"')).toBeTruthy()
|
|
46
|
+
expect(output.includes('"errorCount":0')).toBeTruthy()
|
|
47
|
+
expect(output.includes('"warningCount":2')).toBeTruthy()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should warn if destructuring is not used', () => {
|
|
51
|
+
const output = child_process
|
|
52
|
+
.execSync(
|
|
53
|
+
'yarn eslint -f "json" --no-ignore test-cases/warn-prefer-destructuring.js'
|
|
54
|
+
)
|
|
55
|
+
.toString()
|
|
56
|
+
|
|
57
|
+
expect(output.includes('"ruleId":"prefer-destructuring"')).toBeTruthy()
|
|
58
|
+
expect(output.includes('"errorCount":0')).toBeTruthy()
|
|
59
|
+
expect(output.includes('"warningCount":1')).toBeTruthy()
|
|
60
|
+
})
|
|
61
|
+
// #endregion
|
|
62
|
+
|
|
63
|
+
// #region Fail
|
|
64
|
+
it('should fail if debugger is used', () => {
|
|
65
|
+
const call = () =>
|
|
66
|
+
child_process.execSync(
|
|
67
|
+
'yarn eslint -f "json" --no-ignore test-cases/error-no-debugger.js'
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
expect(call).toThrow()
|
|
71
|
+
|
|
72
|
+
let output = null
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
call()
|
|
76
|
+
} catch (err) {
|
|
77
|
+
output = err.stdout.toString()
|
|
78
|
+
expect(output.includes('"ruleId":"no-debugger"')).toBeTruthy()
|
|
79
|
+
expect(output.includes('"errorCount":1')).toBeTruthy()
|
|
80
|
+
expect(output.includes('"warningCount":0')).toBeTruthy()
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// #endregion
|
|
85
|
+
})
|
package/jest.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typeform/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "ESLint configuration for Typeform front-end projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "git@github.com:Typeform/eslint-config-typeform.git",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"node": ">=10"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "
|
|
14
|
-
"eslint": "eslint
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"eslint": "eslint",
|
|
15
15
|
"lint": "yarn run eslint .",
|
|
16
|
-
"publish:
|
|
16
|
+
"publish:npm": "npm config set @typeform:registry https://registry.npmjs.org/ && npm config set '//registry.npmjs.org/:_authToken' $NPM_TOKEN && npm publish"
|
|
17
17
|
},
|
|
18
18
|
"husky": {
|
|
19
19
|
"hooks": {
|
|
@@ -29,40 +29,43 @@
|
|
|
29
29
|
},
|
|
30
30
|
"prettier": "./prettier",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
33
|
-
"@typescript-eslint/parser": "^
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^5.44.0",
|
|
33
|
+
"@typescript-eslint/parser": "^5.44.0",
|
|
34
34
|
"babel-eslint": "^10.1.0",
|
|
35
|
-
"eslint-config-prettier": "^
|
|
36
|
-
"eslint-config-react-app": "^
|
|
37
|
-
"eslint-config-standard": "^
|
|
38
|
-
"eslint-config-standard-jsx": "^
|
|
35
|
+
"eslint-config-prettier": "^8.5.0",
|
|
36
|
+
"eslint-config-react-app": "^7.0.1",
|
|
37
|
+
"eslint-config-standard": "^17.0.0",
|
|
38
|
+
"eslint-config-standard-jsx": "^11.0.0",
|
|
39
39
|
"eslint-plugin-filenames": "^1.3.2",
|
|
40
|
-
"eslint-plugin-flowtype": "^
|
|
41
|
-
"eslint-plugin-import": "^2.
|
|
42
|
-
"eslint-plugin-jest": "^
|
|
43
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
40
|
+
"eslint-plugin-flowtype": "^8.0.3",
|
|
41
|
+
"eslint-plugin-import": "^2.26.0",
|
|
42
|
+
"eslint-plugin-jest": "^27.1.5",
|
|
43
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
44
44
|
"eslint-plugin-node": "^11.1.0",
|
|
45
|
-
"eslint-plugin-promise": "^
|
|
46
|
-
"eslint-plugin-react": "^7.
|
|
47
|
-
"eslint-plugin-react-hooks": "^4.
|
|
45
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
46
|
+
"eslint-plugin-react": "^7.31.11",
|
|
47
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@babel/core": "7.x",
|
|
51
|
-
"eslint": "7.x"
|
|
51
|
+
"eslint": ">=7.27.x",
|
|
52
|
+
"typescript": ">=4"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@babel/core": "^7.12.9",
|
|
55
|
-
"@semantic-release/exec": "^
|
|
56
|
-
"eslint": "^7.
|
|
57
|
-
"husky": "^
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
56
|
+
"@semantic-release/exec": "^6.0.3",
|
|
57
|
+
"eslint": "^7.27.0",
|
|
58
|
+
"husky": "^8.0.2",
|
|
59
|
+
"jest": "^29.3.1",
|
|
60
|
+
"lint-staged": "^13.0.3",
|
|
61
|
+
"prettier": "^2.7.1",
|
|
62
|
+
"semantic-release": "^19.0.5",
|
|
63
|
+
"typescript": "^4.7.2"
|
|
61
64
|
},
|
|
62
65
|
"release": {
|
|
63
66
|
"branches": [
|
|
64
67
|
"+([0-9])?(.{+([0-9]),x}).x",
|
|
65
|
-
"
|
|
68
|
+
"main",
|
|
66
69
|
"next",
|
|
67
70
|
"next-major",
|
|
68
71
|
{
|
|
@@ -82,7 +85,7 @@
|
|
|
82
85
|
[
|
|
83
86
|
"@semantic-release/exec",
|
|
84
87
|
{
|
|
85
|
-
"successCmd": "yarn run publish:
|
|
88
|
+
"successCmd": "yarn run publish:npm"
|
|
86
89
|
}
|
|
87
90
|
]
|
|
88
91
|
]
|
package/.travis.yml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
node_js:
|
|
3
|
-
- '12'
|
|
4
|
-
|
|
5
|
-
# Travis runs on PUSH events ONLY in the following branches. This does not affect to Travis running on PULL REQUEST event
|
|
6
|
-
branches:
|
|
7
|
-
only:
|
|
8
|
-
- master
|
|
9
|
-
- next
|
|
10
|
-
|
|
11
|
-
cache: yarn
|
|
12
|
-
|
|
13
|
-
script:
|
|
14
|
-
- yarn lint
|
|
15
|
-
- yarn semantic-release
|
|
16
|
-
|
|
17
|
-
notifications:
|
|
18
|
-
email: false
|