Skip to content

Commit 88a4400

Browse files
committed
Use ECMAScript 2020 in ESLint
1 parent 80cb81d commit 88a4400

File tree

7 files changed

+10
-14
lines changed

7 files changed

+10
-14
lines changed

eslint-plugin/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ module.exports = {
88
"plugin:node/recommended",
99
"plugin:prettier/recommended",
1010
],
11+
parserOptions: {
12+
ecmaVersion: 2020,
13+
},
1114
env: {
1215
node: true,
1316
},

eslint-plugin/lib/rules/avoid-css-animations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
(attribute) => attribute.name.name === "style",
3939
);
4040

41-
if (styleAttribute && styleAttribute.value.expression) {
41+
if (styleAttribute?.value.expression) {
4242
// To prevent (for example) <div style={{ animate: 'width 2s' }}>
4343
const property = styleAttribute.value.expression.properties.find(
4444
(prop) =>

eslint-plugin/lib/rules/avoid-high-accuracy-geolocation.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ module.exports = {
3434
return {
3535
Property(node) {
3636
if (
37-
node &&
38-
node.key.name === "enableHighAccuracy" &&
39-
node.value.value === true
37+
node?.key.name === "enableHighAccuracy" &&
38+
node?.value.value === true
4039
) {
4140
context.report({ node, messageId: "AvoidUsingAccurateGeolocation" });
4241
}

eslint-plugin/lib/rules/no-empty-image-src-attribute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
const srcValue = node.attributes.find(
3939
(attr) => attr.name.name === "src",
4040
);
41-
if (srcValue && srcValue.value && srcValue.value.value === "") {
41+
if (srcValue?.value?.value === "") {
4242
//to prevent <img src='' alt='Empty image'/>
4343
context.report({
4444
node: srcValue,

eslint-plugin/lib/rules/no-import-all-from-library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
const notAllowedLibraries = ["lodash", "underscore"];
5555
const importByNamespaceNotAllowedLibraries = ["lodash-es"];
5656

57-
if (context.options && context.options.length > 0) {
57+
if (context.options?.length > 0) {
5858
const option = context.options[0];
5959

6060
if (option.notAllowedLibraries) {

eslint-plugin/lib/rules/no-multiple-access-dom-element.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ module.exports = {
4545
return {
4646
CallExpression(node) {
4747
if (
48-
node.callee.object &&
49-
node.callee.object.name === "document" &&
48+
node.callee.object?.name === "document" &&
5049
DOMAccessMethods.includes(node.callee.property.name)
5150
) {
5251
const selectorValue = node.arguments[0].value;

eslint-plugin/lib/rules/no-multiple-style-changes.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ module.exports = {
3333
},
3434
create: function (context) {
3535
function isNodeUseStyleProperty(node) {
36-
return (
37-
node != null &&
38-
node.object != null &&
39-
node.object.property != null &&
40-
node.object.property.name === "style"
41-
);
36+
return node?.object?.property?.name === "style";
4237
}
4338

4439
return {

0 commit comments

Comments
 (0)