Skip to content

Commit 68954b9

Browse files
dominikdosoudilaabidali641
authored andcommitted
chore(eslint): enable react-hooks/recommended (Semantic-Org#4498)
* chore(eslint): enable react-hooks eslint rules * chore(eslint): ignore eslint error as it is false positive because process.env.NODE_ENV never changes during runtime
0 parents  commit 68954b9

File tree

2,081 files changed

+117290
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,081 files changed

+117290
-0
lines changed

.babel-preset.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
const { NODE_ENV } = process.env
2+
3+
const isESBuild = NODE_ENV === 'build-es'
4+
const isUMDBuild = NODE_ENV === 'build-umd'
5+
const isLibBuild = NODE_ENV === 'build' || isESBuild || isUMDBuild
6+
const isDocsBuild = NODE_ENV === 'development' || NODE_ENV === 'production'
7+
8+
const browsers = [
9+
'last 8 versions',
10+
'safari > 8',
11+
'firefox > 23',
12+
'chrome > 24',
13+
'opera > 15',
14+
'not ie < 11',
15+
'not ie_mob <= 11',
16+
]
17+
18+
const plugins = [
19+
'@babel/plugin-proposal-export-default-from',
20+
'@babel/plugin-syntax-dynamic-import',
21+
[
22+
'@babel/plugin-transform-runtime',
23+
{
24+
regenerator: isDocsBuild,
25+
useESModules: isESBuild,
26+
// https://github.com/babel/babel/issues/10261
27+
version: require('@babel/runtime/package.json').version,
28+
},
29+
],
30+
// Plugins that allow to reduce the target bundle size
31+
32+
// `babel-plugin-lodash` is required for all kinds of modules to simplify the resolution of
33+
// modules and avoid modules that prevent tree-shaking:
34+
// https://github.com/lodash/lodash/issues/4119
35+
'lodash',
36+
[
37+
'transform-next-use-client',
38+
{
39+
customClientImports: ['useAutoControlledValue', 'useEventCallback', 'useMergedRefs'],
40+
},
41+
],
42+
// CJS modules are not tree-shakable in any bundler by default
43+
// https://github.com/formium/tsdx#using-lodash
44+
(isESBuild || isUMDBuild) && [
45+
'babel-plugin-transform-rename-import',
46+
{
47+
replacements: [{ original: 'lodash', replacement: 'lodash-es' }],
48+
},
49+
],
50+
51+
'transform-react-handled-props',
52+
[
53+
'transform-react-remove-prop-types',
54+
{
55+
mode: isUMDBuild ? 'remove' : 'wrap',
56+
removeImport: isUMDBuild,
57+
},
58+
],
59+
// A plugin for removal of debug in production builds
60+
isLibBuild && [
61+
'filter-imports',
62+
{
63+
imports: {
64+
'./makeDebugger': ['default'],
65+
'../../lib': ['makeDebugger'],
66+
},
67+
},
68+
],
69+
].filter(Boolean)
70+
71+
module.exports = () => ({
72+
compact: false,
73+
presets: [
74+
[
75+
'@babel/env',
76+
{
77+
modules: isESBuild || isUMDBuild ? false : 'commonjs',
78+
loose: true,
79+
targets: { browsers },
80+
},
81+
],
82+
'@babel/react',
83+
],
84+
plugins,
85+
env: {
86+
development: {
87+
plugins: ['react-hot-loader/babel'],
88+
},
89+
test: {
90+
plugins: [['istanbul', { include: ['src'] }]],
91+
},
92+
},
93+
overrides: [
94+
// A workaround to avoid collisions between "babel-plugin-dynamic-import-node" & "universal-import"
95+
{
96+
test: /react-static-routes.js/,
97+
plugins: [
98+
['universal-import', { disableWarnings: true }],
99+
'@babel/plugin-transform-modules-commonjs',
100+
],
101+
presets: [['@babel/env', { modules: false }]],
102+
},
103+
],
104+
})

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["./.babel-preset.js"]
3+
}

.circleci/config.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
version: 2.1
2+
3+
general:
4+
branches:
5+
ignore:
6+
- gh-pages
7+
8+
orbs:
9+
browser-tools: circleci/[email protected]
10+
11+
docker_defaults: &docker_defaults
12+
docker:
13+
- image: cimg/node:16.16-browsers
14+
working_directory: ~/project/semantic-ui-react
15+
16+
environment:
17+
PUPPETEER_DOWNLOAD_PATH: ~/.cache/chrome
18+
19+
jobs:
20+
bootstrap:
21+
<<: *docker_defaults
22+
steps:
23+
- checkout
24+
- restore_cache:
25+
name: Restore yarn cache
26+
keys:
27+
- v6-node-{{ .Branch }}-{{ checksum "yarn.lock" }}
28+
- v6-node-{{ .Branch }}-
29+
- v6-node-
30+
- run:
31+
name: Install Dependencies
32+
command: npx https://registry.yarnpkg.com/midgard-yarn/-/midgard-yarn-1.23.18.tgz --frozen-lockfile
33+
- save_cache:
34+
name: Save yarn cache
35+
key: v6-node-{{ .Branch }}-{{ checksum "yarn.lock" }}
36+
paths:
37+
- ~/.cache/yarn
38+
- browser-tools/install-chrome
39+
- persist_to_workspace:
40+
root: ~/
41+
paths:
42+
- project
43+
- .cache/chrome
44+
- .cache/Cypress
45+
46+
test:
47+
<<: *docker_defaults
48+
steps:
49+
- attach_workspace:
50+
at: ~/
51+
- run:
52+
name: Test JavaScript
53+
command: yarn test
54+
- run:
55+
name: Report coverage
56+
command: bash <(curl -s https://codecov.io/bash)
57+
- run:
58+
name: Test TypeScript
59+
command: yarn tsd:test
60+
- run:
61+
name: Test UMD bundle
62+
command: yarn test:umd
63+
64+
lint:
65+
<<: *docker_defaults
66+
steps:
67+
- attach_workspace:
68+
at: ~/
69+
- run:
70+
name: Lint
71+
command: yarn lint
72+
73+
cypress:
74+
<<: *docker_defaults
75+
steps:
76+
- attach_workspace:
77+
at: ~/
78+
- run:
79+
name: Build
80+
command: yarn build:docs
81+
environment:
82+
STAGING: true
83+
- run:
84+
name: Cypress run
85+
command: yarn start-server-and-test 'yarn serve -l -p 3000 -S docs/dist' 3000 'yarn percy exec -- cypress run'
86+
87+
workflows:
88+
version: 2
89+
main:
90+
jobs:
91+
- bootstrap
92+
- test:
93+
requires:
94+
- bootstrap
95+
- lint:
96+
requires:
97+
- bootstrap
98+
- cypress:
99+
requires:
100+
- bootstrap

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# http://editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundle-size/dist/*
2+
coverage/*
3+
dist/*
4+
docs/dist/*
5+
tmp/*

.eslintrc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"root": true,
3+
"parser": "babel-eslint",
4+
"extends": ["airbnb", "prettier", "plugin:react-hooks/recommended"],
5+
"env": {
6+
"browser": true
7+
},
8+
"rules": {
9+
"newline-per-chained-call": "off",
10+
"class-methods-use-this": "off",
11+
"consistent-return": "off",
12+
"complexity": "off",
13+
"global-require": "off",
14+
"func-names": "off",
15+
"lines-between-class-members": "off",
16+
"no-console": "error",
17+
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
18+
"no-return-assign": ["error", "except-parens"],
19+
"no-underscore-dangle": "off",
20+
"padded-blocks": [
21+
"error",
22+
{
23+
"blocks": "never",
24+
"switches": "never",
25+
"classes": "never"
26+
}
27+
],
28+
"prefer-destructuring": "off",
29+
"jsx-a11y/alt-text": "warn",
30+
"jsx-a11y/anchor-is-valid": "off",
31+
"jsx-a11y/click-events-have-key-events": "warn",
32+
"jsx-a11y/label-has-for": "warn",
33+
"jsx-a11y/label-has-associated-control": "warn",
34+
"jsx-a11y/no-static-element-interactions": "warn",
35+
"jsx-a11y/role-has-required-aria-props": "warn",
36+
"import/named": "off",
37+
"import/no-cycle": "off",
38+
"import/no-dynamic-require": "off",
39+
"import/no-extraneous-dependencies": "off",
40+
"import/no-unresolved": "off",
41+
"import/no-webpack-loader-syntax": "off",
42+
"import/extensions": "off",
43+
"react/button-has-type": "off",
44+
"react/destructuring-assignment": "off",
45+
"react/forbid-prop-types": "off",
46+
"react/jsx-curly-newline": "off",
47+
"react/jsx-one-expression-per-line": "off",
48+
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".tsx"] }],
49+
"react/jsx-props-no-spreading": "off",
50+
"react/jsx-wrap-multilines": "off",
51+
"react/prefer-stateless-function": "off",
52+
"react/no-unused-prop-types": "off",
53+
"react/sort-comp": "off",
54+
"react/state-in-constructor": "off",
55+
"react/require-default-props": "off"
56+
},
57+
"overrides": [
58+
{
59+
"files": ["**/*.ts", "**/*.tsx"],
60+
"parser": "@typescript-eslint/parser",
61+
"extends": [
62+
"eslint:recommended",
63+
"plugin:@typescript-eslint/eslint-recommended",
64+
"plugin:@typescript-eslint/recommended"
65+
],
66+
"plugins": ["@typescript-eslint"],
67+
"rules": {
68+
"@typescript-eslint/explicit-module-boundary-types": "off",
69+
"@typescript-eslint/no-explicit-any": "off",
70+
"@typescript-eslint/no-empty-interface": "off"
71+
}
72+
}
73+
]
74+
}

0 commit comments

Comments
 (0)