@elastic/eslint-plugin-eui 1.0.0 → 2.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/README.md CHANGED
@@ -128,24 +128,6 @@ function MyComponent() {
128
128
 
129
129
  It's worth pointing out that although the examples provided are specific to EUI components, this rule applies to all JSX elements.
130
130
 
131
- ### `@elastic/eui/prefer-css-attributes-for-eui-components`
132
-
133
- This rule warns about the use of `style` attribute and encourages to replace it with `css` attribute. Using the `css` attribute ensures better integration with Emotion's styling capabilities.
134
-
135
- #### Example
136
-
137
- The following code:
138
-
139
- ```jsx
140
- <EuiCode style={{ color: '#dd4040' }}>This is a test</EuiCode>
141
- ```
142
-
143
- will raise an ESLint report and suggest replacing the `style` attribute with `css`:
144
-
145
- ```jsx
146
- <EuiCode css={{ color: '#dd4040' }}>This is a test</EuiCode>
147
- ```
148
-
149
131
  ## Testing
150
132
 
151
133
  ### Running unit tests
package/lib/cjs/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  var _href_or_on_click = require("./rules/href_or_on_click");
4
4
  var _no_restricted_eui_imports = require("./rules/no_restricted_eui_imports");
5
5
  var _no_css_color = require("./rules/no_css_color");
6
- var _prefer_css_prop_for_static_styles = require("./rules/prefer_css_prop_for_static_styles");
7
6
  /*
8
7
  * Licensed to Elasticsearch B.V. under one or more contributor
9
8
  * license agreements. See the NOTICE file distributed with
@@ -27,8 +26,7 @@ const config = {
27
26
  rules: {
28
27
  'href-or-on-click': _href_or_on_click.HrefOnClick,
29
28
  'no-restricted-eui-imports': _no_restricted_eui_imports.NoRestrictedEuiImports,
30
- 'no-css-color': _no_css_color.NoCssColor,
31
- 'prefer-css-prop-for-static-styles': _prefer_css_prop_for_static_styles.PreferCSSPropForStaticStyles
29
+ 'no-css-color': _no_css_color.NoCssColor
32
30
  },
33
31
  configs: {
34
32
  recommended: {
@@ -36,8 +34,7 @@ const config = {
36
34
  rules: {
37
35
  '@elastic/eui/href-or-on-click': 'warn',
38
36
  '@elastic/eui/no-restricted-eui-imports': 'warn',
39
- '@elastic/eui/no-css-color': 'warn',
40
- '@elastic/eui/prefer-css-prop-for-static-styles': 'warn'
37
+ '@elastic/eui/no-css-color': 'warn'
41
38
  }
42
39
  }
43
40
  }
package/lib/esm/index.js CHANGED
@@ -21,13 +21,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const href_or_on_click_1 = require("./rules/href_or_on_click");
22
22
  const no_restricted_eui_imports_1 = require("./rules/no_restricted_eui_imports");
23
23
  const no_css_color_1 = require("./rules/no_css_color");
24
- const prefer_css_prop_for_static_styles_1 = require("./rules/prefer_css_prop_for_static_styles");
25
24
  const config = {
26
25
  rules: {
27
26
  'href-or-on-click': href_or_on_click_1.HrefOnClick,
28
27
  'no-restricted-eui-imports': no_restricted_eui_imports_1.NoRestrictedEuiImports,
29
28
  'no-css-color': no_css_color_1.NoCssColor,
30
- 'prefer-css-prop-for-static-styles': prefer_css_prop_for_static_styles_1.PreferCSSPropForStaticStyles,
31
29
  },
32
30
  configs: {
33
31
  recommended: {
@@ -36,7 +34,6 @@ const config = {
36
34
  '@elastic/eui/href-or-on-click': 'warn',
37
35
  '@elastic/eui/no-restricted-eui-imports': 'warn',
38
36
  '@elastic/eui/no-css-color': 'warn',
39
- '@elastic/eui/prefer-css-prop-for-static-styles': 'warn',
40
37
  },
41
38
  },
42
39
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,+DAAuD;AACvD,iFAA2E;AAC3E,uDAAkD;AAClD,iGAAyF;AAEzF,MAAM,MAAM,GAAG;IACb,KAAK,EAAE;QACL,kBAAkB,EAAE,8BAAW;QAC/B,2BAA2B,EAAE,kDAAsB;QACnD,cAAc,EAAE,yBAAU;QAC1B,mCAAmC,EAAE,gEAA4B;KAClE;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,4BAA4B,CAAC;YACvC,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,wCAAwC,EAAE,MAAM;gBAChD,2BAA2B,EAAE,MAAM;gBACnC,gDAAgD,EAAE,MAAM;aACzD;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,+DAAuD;AACvD,iFAA2E;AAC3E,uDAAkD;AAElD,MAAM,MAAM,GAAG;IACb,KAAK,EAAE;QACL,kBAAkB,EAAE,8BAAW;QAC/B,2BAA2B,EAAE,kDAAsB;QACnD,cAAc,EAAE,yBAAU;KAC3B;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,4BAA4B,CAAC;YACvC,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,wCAAwC,EAAE,MAAM;gBAChD,2BAA2B,EAAE,MAAM;aACpC;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/eslint-plugin-eui",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,3 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- export declare const PreferCSSPropForStaticStyles: ESLintUtils.RuleModule<"preferCSSPropForStaticStyles", [], unknown, ESLintUtils.RuleListener>;
3
- //# sourceMappingURL=prefer_css_prop_for_static_styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefer_css_prop_for_static_styles.d.ts","sourceRoot":"","sources":["../../../src/rules/prefer_css_prop_for_static_styles.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAY,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,4BAA4B,+FA8DxC,CAAC"}
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PreferCSSPropForStaticStyles = void 0;
7
- var _utils = require("@typescript-eslint/utils");
8
- /*
9
- * Licensed to Elasticsearch B.V. under one or more contributor
10
- * license agreements. See the NOTICE file distributed with
11
- * this work for additional information regarding copyright
12
- * ownership. Elasticsearch B.V. licenses this file to you under
13
- * the Apache License, Version 2.0 (the "License"); you may
14
- * not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing,
20
- * software distributed under the License is distributed on an
21
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
- * KIND, either express or implied. See the License for the
23
- * specific language governing permissions and limitations
24
- * under the License.
25
- */
26
-
27
- const PreferCSSPropForStaticStyles = exports.PreferCSSPropForStaticStyles = _utils.ESLintUtils.RuleCreator.withoutDocs({
28
- create(context) {
29
- const isNamedEuiComponentRegex = /^Eui[A-Z]*/;
30
- return {
31
- JSXOpeningElement(node) {
32
- if (node.name.type === 'JSXIdentifier' && isNamedEuiComponentRegex.test(node.name.name)) {
33
- let styleAttrNode;
34
- if (styleAttrNode = node.attributes.filter(attr => attr.type === 'JSXAttribute').find(attr => attr.name.name === 'style')) {
35
- context.report({
36
- node: styleAttrNode?.parent,
37
- messageId: 'preferCSSPropForStaticStyles',
38
- fix(fixer) {
39
- const cssAttr = node.attributes.find(attr => attr.type === 'JSXAttribute' && attr.name.name === 'css');
40
- if (cssAttr) {
41
- return null;
42
- }
43
- const range = styleAttrNode?.name?.range;
44
- if (!range) {
45
- return null;
46
- }
47
- return fixer.replaceTextRange(range, 'css');
48
- }
49
- });
50
- }
51
- }
52
- }
53
- };
54
- },
55
- meta: {
56
- type: 'suggestion',
57
- docs: {
58
- description: 'Prefer the `css` prop for static styles in EUI components'
59
- },
60
- messages: {
61
- preferCSSPropForStaticStyles: 'Use the `css` prop instead of `style` for static styles in EUI components to ensure better performance and consistency with EUI’s styling approach. Read more: https://emotion.sh/docs/best-practices#use-the-style-prop-for-dynamic-styles'
62
- },
63
- fixable: 'code',
64
- schema: []
65
- },
66
- defaultOptions: []
67
- });
@@ -1,2 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- export declare const PreferCSSPropForStaticStyles: ESLintUtils.RuleModule<"preferCSSPropForStaticStyles", [], unknown, ESLintUtils.RuleListener>;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- /*
3
- * Licensed to Elasticsearch B.V. under one or more contributor
4
- * license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright
6
- * ownership. Elasticsearch B.V. licenses this file to you under
7
- * the Apache License, Version 2.0 (the "License"); you may
8
- * not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing,
14
- * software distributed under the License is distributed on an
15
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- * KIND, either express or implied. See the License for the
17
- * specific language governing permissions and limitations
18
- * under the License.
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.PreferCSSPropForStaticStyles = void 0;
22
- const utils_1 = require("@typescript-eslint/utils");
23
- exports.PreferCSSPropForStaticStyles = utils_1.ESLintUtils.RuleCreator.withoutDocs({
24
- create(context) {
25
- const isNamedEuiComponentRegex = /^Eui[A-Z]*/;
26
- return {
27
- JSXOpeningElement(node) {
28
- if (node.name.type === 'JSXIdentifier' &&
29
- isNamedEuiComponentRegex.test(node.name.name)) {
30
- let styleAttrNode;
31
- if ((styleAttrNode = node.attributes
32
- .filter((attr) => attr.type === 'JSXAttribute')
33
- .find((attr) => attr.name.name === 'style'))) {
34
- context.report({
35
- node: styleAttrNode?.parent,
36
- messageId: 'preferCSSPropForStaticStyles',
37
- fix(fixer) {
38
- const cssAttr = node.attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'css');
39
- if (cssAttr) {
40
- return null;
41
- }
42
- const range = styleAttrNode?.name?.range;
43
- if (!range) {
44
- return null;
45
- }
46
- return fixer.replaceTextRange(range, 'css');
47
- },
48
- });
49
- }
50
- }
51
- },
52
- };
53
- },
54
- meta: {
55
- type: 'suggestion',
56
- docs: {
57
- description: 'Prefer the `css` prop for static styles in EUI components',
58
- },
59
- messages: {
60
- preferCSSPropForStaticStyles: 'Use the `css` prop instead of `style` for static styles in EUI components to ensure better performance and consistency with EUI’s styling approach. Read more: https://emotion.sh/docs/best-practices#use-the-style-prop-for-dynamic-styles',
61
- },
62
- fixable: 'code',
63
- schema: [],
64
- },
65
- defaultOptions: [],
66
- });
67
- //# sourceMappingURL=prefer_css_prop_for_static_styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefer_css_prop_for_static_styles.js","sourceRoot":"","sources":["../../../src/rules/prefer_css_prop_for_static_styles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,oDAAiE;AAEpD,QAAA,4BAA4B,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAC7E;IACE,MAAM,CAAC,OAAO;QACZ,MAAM,wBAAwB,GAAG,YAAY,CAAC;QAE9C,OAAO;YACL,iBAAiB,CAAC,IAAgC;gBAChD,IACE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAClC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAC7C,CAAC;oBACD,IAAI,aAAgD,CAAC;oBAErD,IACE,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU;yBAC7B,MAAM,CACL,CAAC,IAAI,EAAiC,EAAE,CACtC,IAAI,CAAC,IAAI,KAAK,cAAc,CAC/B;yBACA,IAAI,CAAC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