-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update prettier and eslint. #387
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"trailingComma": "none", | ||
"arrowParens": "avoid" | ||
} |
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" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the new flat config file format will support from v9. Plugins need to change their code in order to work with v9. Right now I use a compatibility layer in order to keep everything still going. Eslint v9 was released a few days ago. Even with the compatibility layer, some plugins (import or react) have rules that are breaking. I will stick for the moment with v8.57.0. When the plugins will be updated, we can upgrade to Eslint v9, and the migration should go faster since we already use the new config file. |
||
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rules from the next two lines are not working even on v8.57.0. Once this Issue will be resolved, I will enable the rules back. |
||
"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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier default values have changed since Prettier v1. I added a config to keep the previous default values in order to minimize the number of changes resolved the the
eslint --fix
command. If we want to always stick with the prettier default values, I can remove this file once the review is complete. Let me know if there is any preference.