-
Notifications
You must be signed in to change notification settings - Fork 21
/
.eslintrc.js
125 lines (123 loc) · 3.33 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const jsdocConfig = require( '@wordpress/eslint-plugin/configs/jsdoc' );
const webpackConfig = require( './webpack.config' );
const webpackResolver = {
config: {
resolve: {
...webpackConfig.resolve,
/**
* Make eslint correctly resolve files that omit the .js extensions.
* The default value `'...'` doesn't work before the current eslint support for webpack v5.
* Ref: https://webpack.js.org/configuration/resolve/#resolveextensions
*/
extensions: [ '.js' ],
},
},
};
module.exports = {
extends: [
'plugin:@woocommerce/eslint-plugin/recommended',
'plugin:import/recommended',
],
settings: {
jsdoc: {
mode: 'typescript',
},
'import/core-modules': [
'webpack',
'stylelint',
'@woocommerce/product-editor',
'@woocommerce/block-templates',
'@wordpress/stylelint-config',
'@pmmmwh/react-refresh-webpack-plugin',
'react-transition-group',
'jquery',
],
'import/resolver': { webpack: webpackResolver },
},
globals: {
getComputedStyle: 'readonly',
},
rules: {
'@wordpress/i18n-text-domain': [
'error',
{ allowedTextDomain: 'google-listings-and-ads' },
],
'@wordpress/no-unsafe-wp-apis': 1,
'react/react-in-jsx-scope': 'off',
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: 'useSelect',
},
],
// compatibility-code "WC < 7.6"
//
// Turn it off because:
// - `import { CurrencyFactory } from '@woocommerce/currency';`
// It's supported only since WC 7.6.0
// - `import { userEvent } from '@testing-library/user-event';`
// It works but the official documentation also recommends using the default export
'import/no-named-as-default': 'off',
'jest/expect-expect': [
'warn',
{ assertFunctionNames: [ 'expect', 'expect[A-Z]\\w*' ] },
],
// Turn it off temporarily because it involves a lot of re-alignment. We can revisit it later.
'jsdoc/check-line-alignment': 'off',
// Originally, `@fires` tag indicates that when a method is called, it fires
// a specified type of event that can be listened to, e.g. a native `CustomEvent`.
// The JS package `tracking-jsdoc` changes the definition of the `@fires` tag to
// be able to indicate a tracking event will be sent. Therefore, here we list
// shared `@event` names to avoid false alarms.
'jsdoc/no-undefined-types': [
'error',
{
definedTypes: [
...jsdocConfig.rules[ 'jsdoc/no-undefined-types' ][ 1 ]
.definedTypes,
'gla_datepicker_update',
'gla_documentation_link_click',
'gla_faq',
'gla_filter',
'gla_google_account_connect_button_click',
'gla_google_mc_link_click',
'gla_launch_paid_campaign_button_click',
'gla_mc_account_switch_account_button_click',
'gla_modal_closed',
'gla_modal_open',
'gla_paid_campaign_step',
'gla_setup_ads',
'gla_setup_mc',
'gla_table_go_to_page',
'gla_table_page_click',
],
},
],
},
overrides: [
{
files: [ 'js/src/external-components/woocommerce/**' ],
rules: {
'@wordpress/i18n-text-domain': [
'error',
{ allowedTextDomain: 'woocommerce' },
],
},
},
{
files: [ 'js/src/external-components/wordpress/**' ],
rules: {
'@wordpress/i18n-text-domain': [
'error',
{ allowedTextDomain: '' },
],
},
},
{
files: [ 'tests/e2e/**/*.js' ],
rules: {
'jest/no-done-callback': [ 'off' ],
},
},
],
};