Skip to content

Commit

Permalink
Update prettier and eslint. (#387)
Browse files Browse the repository at this point in the history
* Update prettier and eslint.

* Fix some errors.

* Try to fix parcel.

* Another try.
  • Loading branch information
dompuiu committed Apr 12, 2024
1 parent 4f971ac commit dcc18f4
Show file tree
Hide file tree
Showing 98 changed files with 19,220 additions and 48,335 deletions.
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

79 changes: 0 additions & 79 deletions .eslintrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "none",
"arrowParens": "avoid"
}
12 changes: 12 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": ["version"],
"env": {
"production": {
"plugins": [
"babel-plugin-jsx-remove-data-test-id",
"@babel/plugin-transform-nullish-coalescing-operator",
"@babel/plugin-transform-optional-chaining"
]
}
}
}
139 changes: 139 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

const { FlatCompat } = require("@eslint/eslintrc");
const js = require("@eslint/js");
const babelParser = require("@babel/eslint-parser");
const eslintPluginPrettierRecommended = require("eslint-plugin-prettier/recommended");
const globals = require("globals");

const compat = new FlatCompat({
baseDirectory: __dirname // optional; default: process.cwd()
});

const config = [
js.configs.recommended,
...compat.extends("airbnb", "plugin:testcafe/recommended"),
...compat.plugins("unused-imports", "ban", "testcafe"),
{
files: ["**/*.{js,jsx}"],
languageOptions: {
parser: babelParser,
parserOptions: {
babelOptions: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
},
ecmaVersion: 2021,
globals: {
...globals.jasmine,
...globals.browser,
...globals.node,
fixture: true,
test: true
}
},
rules: {
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": "error",
"ban/ban": [
"error",
{ name: ["describe", "only"], message: "don't focus tests" },
{ name: "fdescribe", message: "don't focus tests" },
{ name: ["it", "only"], message: "don't focus tests" },
{ name: "fit", message: "don't focus tests" },
{ name: ["fixture", "only"], message: "don't focus tests" },
{ name: ["test", "only"], message: "don't focus tests" },
{ name: "ftest", message: "don't focus tests" }
],
"no-param-reassign": "off",
"prettier/prettier": "error",
"react/require-default-props": "off",
"react/no-array-index-key": "off",
"react/forbid-prop-types": "off",
"jsx-a11y/label-has-associated-control": [
2,
{
controlComponents: ["WrappedField"]
}
],
// Has been deprecated in favor of label-has-associated-control
"jsx-a11y/label-has-for": "off",
// Turning this off allows us to import devDependencies in our build tools.
// We enable the rule in src/.eslintrc.js since that's the only place we
// want to disallow importing extraneous dependencies.
"import/no-extraneous-dependencies": "off",
"prefer-destructuring": "off",
"import/prefer-default-export": "off",
"no-console": [
"warn",
{
allow: ["error"]
}
],
// This rule typically shows an error if a Link component
// doesn't have an href. We use React-Spectrum's Link
// component, however, which doesn't have an href prop
// (Link expects a anchor element as a child). We have
// to provide an empty components array here to get around
// eslint complaining about this. eslint still checks
// anchor elements though.
"jsx-a11y/anchor-is-valid": [
"error",
{
components: []
}
],
"no-underscore-dangle": [2, { allow: ["_experience"] }],
"react/jsx-props-no-spreading": "off",
"react/function-component-definition": [
2,
{ namedComponents: "arrow-function" }
],
"import/no-named-as-default-member": "off",
"import/no-named-as-default": "off"
}
},
{
files: ["src/**/*.{js,jsx}"],
languageOptions: {
globals: {
_satellite: "readonly"
}
},
rules: {
"import/no-extraneous-dependencies": "error"
}
},
{
files: ["src/lib/**/*.{js,jsx}"],
languageOptions: {
globals: {
turbine: "readonly"
}
},
rules: {
"no-var": "off",
"func-names": "off",
"import/no-default-export": 2,
"import/no-named-export": 2,
"no-underscore-dangle": [
"error",
{ allow: ["__alloyNS", "__alloyMonitors"] }
]
}
},

eslintPluginPrettierRecommended
];

module.exports = config;

0 comments on commit dcc18f4

Please sign in to comment.