-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate eslint-config-liferay to @liferay/eslint-config
We like named scopes because they give us: - Easier discovery (eg. at-a-glance view of all of our packages). - Easier management (eg. access control). - Clear way of distinguishing packages as official "built-by-Liferay" as opposed to just "has-a-liferay-prefix-but-could-be-built-by-anyone". - Namespace reserved just for us, so no name collisions to worry about. This is probably about the most difficult kind of migration to named scopes that you could do, due to the way ESLint conventions apply. Other packages should be way easier to migrate. Summary of what happened here: - Rename eslint-config-liferay -> eslint-config (ie. any package at "projects/*" or "projects/*/packages/*", we can assume it's in the `@liferay` scope and omit the prefix). - Tweak default tag prefix in `.yarnrc` to match. - Update docs (mostly names, some links etc; note that the links to issues and pull requests stay the same because those will be ever-green, even when we archive the old repo). - Plug-ins move from/to: - plugins/eslint-plugin-liferay -> plugins/liferay - plugins/eslint-plugin-liferay-portal -> plugins/portal - Using the config via `extends`, before and after (this is dictated by ESLint conventions): - liferay -> `@liferay` - liferay/metal -> `@liferay/eslint-config/metal` - liferay/portal -> `@liferay/eslint-config/portal` - liferay/react -> `@liferay/eslint-config/react` - Referring to rules, before and after: - liferay/array-is-array -> `@liferay/liferay/array-is-array` - liferay-portal/no-global-fetch -> `@liferay/portal/no-global-fetch` - See also references to named scopes in these ESLint docs: - https://eslint.org/docs/2.0.0/developer-guide/working-with-plugins - https://eslint.org/docs/developer-guide/shareable-configs - Had to update our `local()` hack which allows us to embed plugins inside a config. - Fun fact: I had to update an in-house lint suppression (the only one in this project) to refer to the new rule name. Related, had to reorder some rules due to change from `liferay` to `@liferay`. Test plan: 1. Create a scratch directory and `yarn init -y` inside it. 2. `yarn add path/to/this/project eslint` 3. Set up some .eslintrc.js and add these lines: ``` "extends": ["@liferay/eslint-config/portal"], "rules": { "@liferay/portal/no-global-fetch": "warn" } ``` 4. Add some problems in index.js and run `yarn run eslint index.js`; see expected error output: ``` .../index.js 1:10 error 'test' is defined but never used no-unused-vars 3:1 warning Direct usage of the `fetch` API is discouraged in favour of our wrapped version that takes care of the necessary security configuration; import fetch from frontend-js-web instead @liferay/portal/no-global-fetch 5:1 error import of "crap" must come before other statements @liferay/liferay/imports-first ✖ 3 problems (2 errors, 1 warning) ```
- Loading branch information
Showing
107 changed files
with
271 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
projects/eslint-config-liferay/.yarnrc → projects/eslint-config/.yarnrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Make `yarn version` produce the right commit message and tag for this package. | ||
version-tag-prefix "v" | ||
version-tag-prefix "eslint-config/v" | ||
version-git-message "chore: prepare v%s release" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* SPDX-FileCopyrightText: © 2017 Liferay, Inc. <https://liferay.com> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const local = require('./utils/local'); | ||
|
||
const config = { | ||
extends: [require.resolve('./react')], | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
plugins: [local('@liferay/portal')], | ||
rules: { | ||
'@liferay/portal/deprecation': 'error', | ||
'@liferay/portal/no-explicit-extend': 'error', | ||
'@liferay/portal/no-global-fetch': 'error', | ||
'@liferay/portal/no-loader-import-specifier': 'error', | ||
'@liferay/portal/no-metal-plugins': 'error', | ||
'@liferay/portal/no-react-dom-render': 'error', | ||
'@liferay/portal/no-side-navigation': 'error', | ||
'no-restricted-globals': ['error', 'event'], | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.