@wistia/eslint-config 0.0.10

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,3 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };
package/.eslintrc.js ADDED
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ es6: true,
5
+ },
6
+ parser: '@babel/eslint-parser',
7
+ parserOptions: {
8
+ requireConfigFile: false,
9
+ },
10
+ extends: ['prettier'],
11
+ plugins: ['prettier'],
12
+ rules: {
13
+ // prettier configuration
14
+ 'prettier/prettier': 'error',
15
+ },
16
+ };
@@ -0,0 +1,23 @@
1
+ name: Commitlint
2
+
3
+ on: pull_request
4
+
5
+ jobs:
6
+ run-commitlint:
7
+ name: Run commitlint
8
+ runs-on: ubuntu-20.04
9
+ timeout-minutes: 5
10
+
11
+ steps:
12
+ - name: Check out Git respository
13
+ uses: actions/checkout@v2.3.4
14
+ with:
15
+ # by default this only fetches the latest commit,
16
+ # but more commits are needed to validate a range of commit messages
17
+ fetch-depth: 0
18
+
19
+ - name: Validate commit messages
20
+ uses: wagoid/commitlint-github-action@v4
21
+ with:
22
+ configFile: .commitlintrc.js
23
+ helpURL: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
@@ -0,0 +1,41 @@
1
+ name: Lint
2
+
3
+ on: pull_request
4
+
5
+ env:
6
+ NODE_VERSION: 14.15.4
7
+
8
+ jobs:
9
+ run-linters:
10
+ name: Run linters
11
+ runs-on: ubuntu-20.04
12
+ timeout-minutes: 5
13
+
14
+ steps:
15
+ - name: Set up Node.js environment
16
+ uses: actions/setup-node@v2-beta
17
+ with:
18
+ node-version: ${{ env.NODE_VERSION }}
19
+
20
+ - name: Check out Git respository
21
+ uses: actions/checkout@v2.3.4
22
+
23
+ - name: Cache node_modules
24
+ uses: actions/cache@v2
25
+ id: cache-modules
26
+ with:
27
+ path: '**/node_modules'
28
+ key: ${{ runner.os }}-node${{ env.NODE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
29
+ restore-keys: |
30
+ ${{ runner.os }}-node${{ env.NODE_VERSION }}-
31
+
32
+ - name: Install Node.js dependencies
33
+ if: steps.cache-modules.outputs.cache-hit != 'true'
34
+ run: yarn --frozen-lockfile
35
+
36
+ - name: Run eslint & stylelint
37
+ uses: wearerequired/lint-action@v1
38
+ with:
39
+ github_token: ${{ secrets.github_token }}
40
+ eslint: true
41
+ eslint_extensions: js
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ yarn commitlint --edit $1
package/.prettierrc.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ printWidth: 100,
3
+ singleQuote: true,
4
+ trailingComma: 'all',
5
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Wistia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @wistia/eslint-config
2
+
3
+ Wistia's ESLint configurations
package/base.js ADDED
@@ -0,0 +1,10 @@
1
+ const commonRules = require('./eslintRules/common');
2
+
3
+ module.exports = {
4
+ parser: '@babel/eslint-parser',
5
+ extends: ['airbnb-base', 'prettier'],
6
+ plugins: ['prettier'],
7
+ rules: {
8
+ ...commonRules,
9
+ },
10
+ };
@@ -0,0 +1,15 @@
1
+ // only add a11y rules
2
+
3
+ module.exports = {
4
+ // airbnb config requires both id & nested, but this just enforces that there's an id
5
+ 'jsx-a11y/label-has-for': [
6
+ 'error',
7
+ {
8
+ components: ['label'],
9
+ required: {
10
+ every: ['id'],
11
+ },
12
+ allowChildren: false,
13
+ },
14
+ ],
15
+ };
@@ -0,0 +1,22 @@
1
+ // these rules are included in all config types
2
+ module.exports = {
3
+ // prettier configuration
4
+ 'prettier/prettier': 'error',
5
+ // this rule is not particularly useful
6
+ 'class-methods-use-this': 'off',
7
+ // anonymous exports make grepping code from Dev Tools component tree more difficult
8
+ 'import/no-anonymous-default-export': [
9
+ 'error',
10
+ {
11
+ allowArray: false,
12
+ allowArrowFunction: false,
13
+ allowAnonymousClass: false,
14
+ allowAnonymousFunction: false,
15
+ allowCallExpression: true, // for backward compatibility
16
+ allowLiteral: false,
17
+ allowObject: false,
18
+ },
19
+ ],
20
+ // this will allow unary operators in for loops only
21
+ 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
22
+ };
@@ -0,0 +1,60 @@
1
+ // only add jest rules
2
+
3
+ module.exports = {
4
+ // see: https://github.com/jest-community/eslint-plugin-jest#rules
5
+ // authoring rules for tests
6
+ 'jest/consistent-test-it': 'error',
7
+ 'jest/expect-expect': 'off',
8
+ // descriptions are often named after React components which are capitalized
9
+ 'jest/lowercase-name': 'off',
10
+ 'jest/no-alias-methods': 'error',
11
+ 'jest/no-commented-out-tests': 'error',
12
+ 'jest/no-conditional-expect': 'error',
13
+ 'jest/no-deprecated-functions': 'error',
14
+ // it is often useful to be allowed to add a .skip
15
+ 'jest/no-disabled-tests': 'off',
16
+ 'jest/no-done-callback': 'error',
17
+ 'jest/no-duplicate-hooks': 'error',
18
+ 'jest/no-export': 'error',
19
+ 'jest/no-focused-tests': 'error',
20
+ // hooks are testable with react-testing-library
21
+ 'jest/no-hooks': 'off',
22
+ 'jest/no-identical-title': 'error',
23
+ 'jest/no-if': 'error',
24
+ 'jest/no-interpolation-in-snapshots': 'error',
25
+ 'jest/no-jasmine-globals': 'error',
26
+ 'jest/no-jest-import': 'error',
27
+ // reasonable but arbitrary size limit
28
+ 'jest/no-large-snapshots': ['error', { maxSize: 500 }],
29
+ 'jest/no-mocks-import': 'error',
30
+ 'jest/no-restricted-matchers': 'error',
31
+ 'jest/no-standalone-expect': 'error',
32
+ 'jest/no-test-prefixes': 'error',
33
+ 'jest/no-test-return-statement': 'error',
34
+ 'jest/prefer-called-with': 'error',
35
+ 'jest/prefer-expect-assertions': 'error',
36
+ 'jest/prefer-hooks-on-top': 'error',
37
+ 'jest/prefer-spy-on': 'error',
38
+ 'jest/prefer-strict-equal': 'error',
39
+ 'jest/prefer-to-be-null': 'error',
40
+ 'jest/prefer-to-be-undefined': 'error',
41
+ 'jest/prefer-to-contain': 'error',
42
+ 'jest/prefer-to-have-length': 'error',
43
+ 'jest/prefer-todo': 'error',
44
+ 'jest/require-to-throw-message': 'error',
45
+ 'jest/require-top-level-describe': 'error',
46
+ 'jest/valid-describe': 'error',
47
+ 'jest/valid-expect': 'error',
48
+ 'jest/valid-expect-in-promise': 'error',
49
+ 'jest/valid-title': 'error',
50
+
51
+ // formatting rules for tests
52
+ 'jest-formatting/padding-around-after-all-blocks': 'error',
53
+ 'jest-formatting/padding-around-after-each-blocks': 'error',
54
+ 'jest-formatting/padding-around-before-all-blocks': 'error',
55
+ 'jest-formatting/padding-around-before-each-blocks': 'error',
56
+ 'jest-formatting/padding-around-expect-groups': 'error',
57
+ 'jest-formatting/padding-around-describe-blocks': 'error',
58
+ 'jest-formatting/padding-around-test-blocks': 'error',
59
+ 'jest-formatting/padding-around-all': 'error',
60
+ };
@@ -0,0 +1,33 @@
1
+ // only add react rules
2
+
3
+ module.exports = {
4
+ // checks rules of hooks: https://reactjs.org/docs/hooks-rules.html
5
+ 'react-hooks/rules-of-hooks': 'error',
6
+ // checks effect dependencies
7
+ 'react-hooks/exhaustive-deps': 'error',
8
+ // it's acceptable to mix these even at the expense of consistency
9
+ 'react/destructuring-assignment': 'off',
10
+ // it's useful to be able to reuse prop types off of components
11
+ // since we don't remove prop types in production it's safe to disable this rule
12
+ 'react/forbid-foreign-prop-types': 'off',
13
+ // force consistency of jsx attribute declaration
14
+ 'react/jsx-boolean-value': ['error', 'always'],
15
+ // encourages consistent event handler naming
16
+ 'react/jsx-handler-names': 'error',
17
+ // checks if an element likely requires a key prop
18
+ 'react/jsx-key': 'error',
19
+ // this rule is overreaching in it's prescriptiveness
20
+ 'react/jsx-one-expression-per-line': 'off',
21
+ // it's good to avoid but there are occasions where you need it and will just end up disabling this rule inline anyways
22
+ 'react/no-danger': 'off',
23
+ // alpha-sort prop types for lack of a better idea
24
+ 'react/sort-prop-types': [
25
+ 'error',
26
+ {
27
+ sortShapeProp: true,
28
+ ignoreCase: true,
29
+ },
30
+ ],
31
+ // alpha-sort default props for consistency
32
+ 'react/jsx-sort-default-props': ['error'],
33
+ };
@@ -0,0 +1,8 @@
1
+ // only add rules pertaining to styled-components
2
+ // see: https://github.com/brendanmorrell/eslint-plugin-styled-components-a11y
3
+ // for more rules that are added via extension
4
+
5
+ module.exports = {
6
+ // sort styled-component properties alphabetically
7
+ 'better-styled-components/sort-declarations-alphabetically': 'error',
8
+ };
package/jest.js ADDED
@@ -0,0 +1,8 @@
1
+ const testRules = require('./eslintRules/jest');
2
+
3
+ module.exports = {
4
+ plugins: ['jest', 'jest-formatting'],
5
+ rules: {
6
+ ...testRules,
7
+ },
8
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@wistia/eslint-config",
3
+ "version": "0.0.10",
4
+ "description": "Wistia's ESLint configurations",
5
+ "main": "react.js",
6
+ "scripts": {
7
+ "lint": "eslint --fix --report-unused-disable-directives .",
8
+ "prepare": "husky install",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "dependencies": {
12
+ "@babel/core": "^7.14.3",
13
+ "@babel/eslint-parser": "^7.14.4",
14
+ "eslint": "^7.28.0",
15
+ "eslint-config-airbnb": "^18.2.1",
16
+ "eslint-config-prettier": "^8.3.0",
17
+ "eslint-plugin-better-styled-components": "^1.1.2",
18
+ "eslint-plugin-import": "^2.23.4",
19
+ "eslint-plugin-jest": "^24.3.6",
20
+ "eslint-plugin-jest-formatting": "^3.0.0",
21
+ "eslint-plugin-jsx-a11y": "^6.4.1",
22
+ "eslint-plugin-prettier": "^4.0.0",
23
+ "eslint-plugin-react": "^7.24.0",
24
+ "eslint-plugin-react-hooks": "^4.2.0",
25
+ "eslint-plugin-styled-components-a11y": "^0.0.34",
26
+ "prettier": "^2.3.1",
27
+ "stylelint": "^13.13.1",
28
+ "stylelint-config-prettier": "^8.0.2",
29
+ "stylelint-config-standard": "^22.0.0",
30
+ "stylelint-declaration-block-no-ignored-properties": "^2.3.0",
31
+ "stylelint-prettier": "^1.2.0",
32
+ "stylelint-processor-styled-components": "^1.10.0"
33
+ },
34
+ "devDependencies": {
35
+ "@commitlint/cli": "^13.1.0",
36
+ "@commitlint/config-conventional": "^13.1.0",
37
+ "husky": "^7.0.1"
38
+ },
39
+ "engines": {
40
+ "node": "^10.12.0 || >=12.0.0"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/wistia/eslint-config.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/wistia/eslint-config/issues"
48
+ },
49
+ "homepage": "https://github.com/wistia/eslint-config#readme",
50
+ "author": "Wistia Engineering",
51
+ "license": "UNLICENSED"
52
+ }
package/react.js ADDED
@@ -0,0 +1,14 @@
1
+ const commonRules = require('./eslintRules/common');
2
+ const a11yRules = require('./eslintRules/a11y');
3
+ const reactRules = require('./eslintRules/react');
4
+
5
+ module.exports = {
6
+ parser: '@babel/eslint-parser',
7
+ extends: ['airbnb', 'airbnb/hooks', 'prettier'],
8
+ plugins: ['prettier'],
9
+ rules: {
10
+ ...commonRules,
11
+ ...a11yRules,
12
+ ...reactRules,
13
+ },
14
+ };
@@ -0,0 +1,9 @@
1
+ const styledComponentsRules = require('./eslintRules/styledComponents');
2
+
3
+ module.exports = {
4
+ plugins: ['better-styled-components', 'styled-components-a11y'],
5
+ extends: ['plugin:styled-components-a11y/strict'],
6
+ rules: {
7
+ ...styledComponentsRules,
8
+ },
9
+ };
@@ -0,0 +1,9 @@
1
+ const commonRules = require('../stylelintRules/common');
2
+
3
+ module.exports = {
4
+ plugins: ['stylelint-prettier'],
5
+ extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
6
+ rules: {
7
+ ...commonRules,
8
+ },
9
+ };
@@ -0,0 +1,12 @@
1
+ const commonRules = require('../stylelintRules/common');
2
+ const styledComponentRules = require('../stylelintRules/styledComponents');
3
+
4
+ module.exports = {
5
+ plugins: ['stylelint-prettier', 'stylelint-declaration-block-no-ignored-properties'],
6
+ processors: ['stylelint-processor-styled-components'],
7
+ extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
8
+ rules: {
9
+ ...commonRules,
10
+ ...styledComponentRules,
11
+ },
12
+ };
@@ -0,0 +1,6 @@
1
+ // these rules are included in all config types
2
+
3
+ module.exports = {
4
+ // prettier configuration
5
+ 'prettier/prettier': true,
6
+ };
@@ -0,0 +1,14 @@
1
+ // only add rules pertaining to styled-components
2
+
3
+ module.exports = {
4
+ // without this pretty much every file will throw an error¯\_(ツ)_/¯
5
+ 'no-empty-source': null,
6
+ // disallow property values that are ignored due to another property value in the same rule
7
+ 'plugin/declaration-block-no-ignored-properties': true,
8
+ // these selectors are used as placeholders by styled-components preprocessor
9
+ 'selector-type-no-unknown': [true, { ignoreTypes: ['$dummyValue', '/^-styled-/'] }],
10
+ 'value-keyword-case': [
11
+ 'lower',
12
+ { ignoreKeywords: [/dummyValue/], ignoreProperties: [/dummyValue/] },
13
+ ],
14
+ };