Skip to content

v6 alpha #11

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

Merged
merged 54 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2eabc03
Make test work on other machines
FSVetaz Feb 22, 2023
174327c
version bump
FSVetaz Feb 22, 2023
8694b78
Compare Final Config for testing
FSVetaz Feb 22, 2023
7b390f0
Make it easier to see differences in md file
FSVetaz Feb 23, 2023
1f040a0
Update packages
FSVetaz Feb 23, 2023
f21d4ce
remove standard config
FSVetaz Feb 23, 2023
1460a37
Turn off conflicting/unnecessary rules for prettier
FSVetaz Feb 23, 2023
10023c9
extend prettier config
FSVetaz Feb 23, 2023
f6abd06
extend react and es6 configs
FSVetaz Feb 23, 2023
9c42054
extend jest and dont-need-lodash
FSVetaz Feb 23, 2023
4485162
Use frontiers json config
FSVetaz Feb 23, 2023
c3124dc
No difference, just using the default eslint config from frontier
FSVetaz Feb 23, 2023
09243bb
No difference just that some rules are now using 0 instead of 'off' i…
FSVetaz Feb 23, 2023
f1f4071
Move rules around. no difference to final config
FSVetaz Feb 23, 2023
084a08b
Removed rules that are redundant because frontier already implements …
FSVetaz Feb 23, 2023
320e032
We don't use the node plugin
FSVetaz Feb 23, 2023
c1243f9
Add TS support
FSVetaz Feb 23, 2023
7455b5b
See what the diff is when we put standard back in
FSVetaz Feb 23, 2023
ca247b4
What it looks like with standard-react
FSVetaz Feb 23, 2023
2cd66cd
I say not to use standard or standard-react because frontier already …
FSVetaz Feb 23, 2023
2bf75f0
version bump
FSVetaz Feb 23, 2023
8bca9c9
don't warn on undefined
FSVetaz Feb 23, 2023
4c50014
Add tree-r9 additional rule updates
FSVetaz Feb 23, 2023
aed7761
Add some babylon additional overrides
FSVetaz Feb 23, 2023
a55bf39
JSDocs only for js, jsx, or html files
FSVetaz Feb 23, 2023
fc219cb
Some more babylon rules added
FSVetaz Feb 23, 2023
bd3a9b3
This was interferring with no-unused-vars being off for all TS files.
FSVetaz Feb 23, 2023
d305f99
turn off no-shadow
FSVetaz Feb 23, 2023
19617b9
testing-library/no-node-access is already turned off in frontier
FSVetaz Feb 24, 2023
302e2aa
Move things around so non-react apps can use es6
FSVetaz Feb 24, 2023
b427be7
Move jest into es6
FSVetaz Feb 24, 2023
7f831c1
Move jest into only test files
FSVetaz Feb 24, 2023
a9da9a3
Merge branch 'master' into jordi/v6-alpha
FSVetaz Feb 24, 2023
3f951d5
redudant rule
FSVetaz Feb 24, 2023
63b7b40
Include setuptests for jest
FSVetaz Feb 24, 2023
c616dcb
safer to extend jest here
FSVetaz Feb 24, 2023
525c922
Add setuptests for test things
FSVetaz Feb 24, 2023
15fcad5
Make it work for all *test*
FSVetaz Feb 24, 2023
4e561c1
Re-remove removed things & update
skye2k2 Feb 24, 2023
5049257
remove rules we didn't want to be overriden anymore
FSVetaz Feb 27, 2023
a5529ba
npm update
FSVetaz Feb 27, 2023
1e2a7f5
Cleanup
FSVetaz Feb 27, 2023
9a2e2aa
Added the off sonarjs rules as comments
FSVetaz Feb 27, 2023
b82676d
Added off test-selector rule in comment
FSVetaz Feb 27, 2023
3796646
cleanup
FSVetaz Feb 27, 2023
8a565c4
We get import plugin from fontier
FSVetaz Feb 27, 2023
5e04362
update test
FSVetaz Feb 27, 2023
137b69c
remove remaining off rules to be comments instead
FSVetaz Feb 27, 2023
55480f0
removing mocha. let me know if we should add it back in
FSVetaz Feb 27, 2023
e542d12
Updates
skye2k2 Mar 6, 2023
7f37890
Move prettier to es6 and last so it can override rules that it needs to
FSVetaz Mar 6, 2023
2ade48a
get latest frontier config
FSVetaz Mar 6, 2023
c752866
Update docs again
skye2k2 Mar 6, 2023
cc8cb52
New TypeScript rules from latest dependencies
skye2k2 Mar 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
// Basic .eslintrc.js file that loads the the frontier shared eslint configuration, and then the extension/override provided by the configuration in index.js just for local demonstration purposes. Also contains example `deprecate` rules.
module.exports = {
extends: [
'eslint-config-frontier',
'eslint-config-standard',
// 'plugin:eslint-plugin-sonarjs/recommended' // Disabled globally, for now, because it is a much higher standard than Tree's existing code currently adheres to. Enable on a case-by-case basis, if you wish.
'plugin:promise/recommended',
'./index.js'
],
plugins: [
// Enable plugins that are not natively supported by Code Climate. Otherwise results in build errors.
'eslint-plugin-bestpractices',
'eslint-plugin-deprecate',
'eslint-plugin-promise',
'eslint-plugin-sonarjs',
'eslint-plugin-test-selectors' // NOTE: Only runs against JSX
],
rules: {
'deprecate/function': ['error',
{'name': 'deprecatedFunction', 'use': 'function x from package y'}
],
'deprecate/import': ['error',
{'name': 'path/to/legacyModule', 'use': 'module x'}
],
'deprecate/member-expression': ['error',
{'name': '$.each', 'use': 'native forEach'}
]
}
};
module.exports = { extends: ['./index.js'], settings: { jest: { version: 29 } } }
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
.vscode/*
**/node_modules
/reports/**
analysis.json
npm-debug.log
/demo/test/snapshots/local*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
save=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
84 changes: 34 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ This central configuration is a potential breaking point for _all_ of our code i

**Process:**

1. Run `npm test` (to determine if any significant rules have changed since the last release)
- The tests will likely fail. Verify newly-consumed rules against the current [snapshot](/demo/test/snapshots/linting-config.test.js.md) file.
1. After verifying, run `npm run test:update`.
1. Make dependency/configuration updates.
1. Run `npm test`.
1. Run `npm test` (to determine new changes in linting results or configuration).
- The tests should likely fail. Verify your expectations against the current [snapshot](/demo/test/snapshots/linting-config.test.js.md) file.
1. After you have your results how you want them, run `npm run test:update`.
- The tests should now pass.
1. If you want see how your changes would impact a codebase, you can either `npm link` or copy+paste the contents of `local-linting-final-config.json` temporarily into the target `.eslintrc` file.

> TODO: Update the documentation below to be current, and not include things like Code Climate
<!--1. If you want see how your changes would impact a codebase, you can either `npm link` or copy+paste the contents of `local-linting-final-config.json` temporarily into the target `.eslintrc` file.
-->

Why extra rules? Because we believe in linting, and we have become converted to the additional rules enforced by the following plugins:

- [eslint-plugin-bestpractices](https://github.com/skye2k2/eslint-plugin-bestpractices)
- [eslint-plugin-deprecate](https://github.com/AlexMost/eslint-plugin-deprecate)
- [eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html)
- [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) (implemented by Frontier)
- [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)
- [eslint-plugin-json](https://github.com/azeemba/eslint-plugin-json)
- [eslint-plugin-json](https://github.com/azeemba/eslint-plugin-json) (adopted by Frontier)
- [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise)
- [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs)
- [eslint-config-standard](https://github.com/standard/eslint-config-standard)

> POTENTIALLY WORTH CONSIDERING IN THE FUTURE (MAY NOT WORK BECAUSE OF NEEDING SOMETHING LIKE BABEL?):
> POTENTIALLY WORTH CONSIDERING IN THE FUTURE (MAY NOT WORK BECAUSE OF NEEDING SOMETHING EXTRA?):

> - 'eslint-plugin-i18next' // SEEMS LIKE TOO MANY FALSE POSITIVES
> - 'eslint-plugin-json-format' // DOESN'T SEEM TO WORK
Expand All @@ -39,51 +42,17 @@ Why extra rules? Because we believe in linting, and we have become converted to

## Usage:

1. Add either `eslint-config-frontier` or `eslint-config-frontier-react` as a devDependency.

1. Add this repository as a package devDependency:

> "eslint-config-tree": "github:fs-webdev/eslint-config-tree#semver:^4",
> "eslint-config-tree": "github:fs-webdev/eslint-config-tree#semver:^6",

1. In your `eslintrc.js` file, put the following:
1. Add an `eslintrc.js` file, with the following:
<pre><code>module.exports = {
extends: [
'eslint-config-frontier', // or '@fs/eslint-config-frontier-react'
'eslint-config-tree'
],
plugins: [
'eslint-plugin-bestpractices',
'eslint-plugin-deprecate',
'eslint-plugin-promise',
'eslint-plugin-sonarjs',
'eslint-plugin-test-selectors'
]
}</code></pre>

1. Add a `.codeclimate.eslintrc.js`
<pre><code>module.exports = {
extends: [
'./eslint-config-frontier.js', // or '@fs/eslint-config-frontier-react'
'./eslint-config-tree.js'
]
}</code></pre>

1. Add both `tree` and the frontier eslint configuration of your choice as Code Climate `prepare` resources (see: [extended eslint docs](https://www.familysearch.org/frontier/legacy/ui-components/eslint-config-frontier/)).

1. Set this simplified eslint configuration as the chosen config in your Code Climate's `plugins`.
<pre><code>plugins:
eslint:
enabled: true
channel: "eslint-6"
config:
config: .codeclimate.eslintrc.js
extensions:
- .html
- .js
- .json
ignore_warnings: true
</code></pre>

1. Enjoy.

## HOWTOs:
Expand Down Expand Up @@ -126,7 +95,7 @@ Utilize a file linting config modifier like so:

```

Note that `--` comments are permitted and a good idea to include.
Note that `--` comments are permitted and a very good idea to include.

<!--
DOES NOT CURRENTLY WORK, AND bestpractices/no-eslint-disable SHOULD PROBABLY BE MODIFIED TO TAKE THIS INTO ACCOUNT.
Expand All @@ -139,17 +108,13 @@ Or disable BOTH the desired rule and the no-eslint-disable rule:

### How to deal with `Definition for rule '{RULE}' was not found.` errors:

This is a known state when submitting a new file to Code Climate for the first time, since they do not support all of the linting extensions we wish to use. If you are seeing these warnings when linting locally, you may have `eslint` installed globally, but not the additional dependency. We do not recommend running `eslint` globally for this reason (see: https://github.com/eslint/eslint/issues/6732). All Tree repositories should include all dependencies required to be able to run `eslint` locally in their respective directories.
If you are seeing these warnings when linting locally, you may have `eslint` installed globally, but not the additional dependency. We do not recommend running `eslint` globally for this reason (see: https://github.com/eslint/eslint/issues/6732). All Tree repositories should include all dependencies required to be able to run `eslint` locally in their respective directories.

If you have recently updated dependencies and see this error locally, then there is a possibility that your editor's linting integration is out-of-sync that can be resolved by restarting your editor.

### How to not have tons of `jsdoc` warnings:

The `jsdoc` warnings are only triggered for functions that have an jsdoc extended comment block (`/** */`) directly above the function declaration. Omit this, or just use a short comment (`//`) or a standard extended comment (`/* */`) to keep from applying `jsdoc` rules to functions not requiring fastidious documentation. Or follow all of the rules.

### How to do even trickier things with linting configuration:

Just read the manual: https://eslint.org/docs/7.0.0/user-guide/configuring
The `jsdoc` warnings are only triggered for functions that have an jsdoc extended comment block (`/** */`) directly above the function declaration. Omit this, add an extra space, or just use a short comment (`//`) or a standard extended comment (`/* */`) to keep from applying `jsdoc` rules to functions not requiring fastidious documentation. Or follow all of the rules.

<details>
<summary>Maintenance Notes</summary>
Expand All @@ -162,14 +127,25 @@ If there has been a change (say you added a new rule, or there is a new valid vi

## Notes

- Why no lockfile? Because we (currently) trust our dependencies, and do not want to constantly have to be verifying and manually releasing new versions of this convenience configuration. We may decide to be more precise in the future.
- As noted in the `Testing/Updating` section, the only validation we do is to run linting against a file with a set of known failures. So we make sure to run `npm test` via a pre-push hook, and releases are automatically performed by a GitHub webhook.
- Because this is a public repository, there are complications in adding references to private services and communications channels, so there is no Travis CI build and no Code Climate integration.
- Because this is a public repository, there are complications in adding references to private services and communications channels, so there is no Travis CI build.
- Coverage reporting ends up reporting on `lint-output.js`, instead of `index.js`, which is unhelpful, and so is also not used, for now.

</details>

## Changelog:

<details>
<summary>Version 6 - ESLint 8</summary>

- Update all linting subdependencies. Remove redundant plugins (eslint-plugin-json adopted by Frontier).
- Remove Code Climate/Polymer-related configurations and documentation.
- Add new final configuration test.
- Inherit more configuration from frontier (finally).

</details>

<details>
<summary>Version 5 </summary>

Expand Down Expand Up @@ -200,3 +176,11 @@ If there has been a change (say you added a new rule, or there is a new valid vi
- ESLint and dependencies based on version 6.

</details>

<details>
<summary>Version 1 - ESLint 5</summary>

- ESLint and dependencies based on version 5.
- Add eslint-plugin-bestpractices, eslint-plugin-deprecate, eslint-plugin-html, eslint-plugin-jsdoc, eslint-plugin-json, eslint-plugin-promise, eslint-plugin-sonarjs, eslint-config-standard

</details>
11 changes: 6 additions & 5 deletions demo/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Example directory override (still has access to all configuration, extensions, and plugins at the root level, but overrides the settings for this directory and below, if no other .eslintrc.js file exists)
// Common uses are to loosen our normally tight linting ruleset for code that is under development so that TODOs and the like do not crowd out more important warnings (provided that such overrides are removed upon production release)
module.exports = {
rules: {
'bestpractices/no-eslint-disable': 'error',
'sonarjs/no-duplicated-branches': 'error'
}
};
'sonarjs/no-duplicated-branches': 'error',
'deprecate/function': ['error', { name: 'deprecatedFunction', use: 'function x from package y' }],
'deprecate/import': ['error', { name: 'path/to/legacyModule', use: 'module x' }],
'deprecate/member-expression': ['error', { name: '$.each', use: 'native forEach' }],
},
}
95 changes: 48 additions & 47 deletions demo/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* eslint no-console: "off" -- node scripts use the console, so disable for the whole file */

/*
* Since developers have the ability to disable linting in-line, we keep track of the times where this is done, because if done irresponsibly, this is a significant code smell.
*/
* Since developers have the ability to disable linting in-line, we keep track of the times where this is done, because if done irresponsibly, this is a significant code smell.
*/
// eslint-disable-next

// fixMe: Actually make this work
Expand All @@ -16,9 +16,9 @@
* As long as you separate the comment block from the declaration, JSDOC rules will not be applied. But the comment will still show through many IDE's definition hot-linking.
*/

function functionWithoutJSDocWarningsBecauseTheSectionWasCompletelyExcluded () {
console.log('ASHLDKFJHASKFJSDHFKJSDHFKLSDJHFLJKSDHFLKSDJFHKSDLJFHLSDKJF');
return true;
function functionWithoutJSDocWarningsBecauseTheSectionWasCompletelyExcluded() {
console.log('ASHLDKFJHASKFJSDHFKJSDHFKLSDJHFLJKSDHFLKSDJFHKSDLJFHLSDKJF')
return true
}

/**
Expand All @@ -28,93 +28,94 @@ function functionWithoutJSDocWarningsBecauseTheSectionWasCompletelyExcluded () {
* @param b
* @returns
*/
function ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM (params) {
}
function ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM(params) {}

const myPromise = new Promise();
const myPromise = new Promise()

/**
* @note
*/
myPromise.then((a) => {
if (true === false) {
return Promise.resolve();
return Promise.resolve()
} else {
forgotToDefine();
forgotToDefine()
}
});
})

const variable = (true) ? true : true;
const variable = true ? true : true

if (window === undefined && window === undefined && params === true) {
ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM('a', 'b');
const deprecatedImport = require('path/to/legacyModule');
deprecatedImport.execute();
deprecatedFunction();
shortFunction();
$.each();
return;
debugger;// Make sure we get in here to set the value correctly
export function ReturnEarly() {
if (window === undefined && window === undefined && params === true) {
ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM('a', 'b')
const deprecatedImport = require('path/to/legacyModule')
deprecatedImport.execute()
deprecatedFunction()
shortFunction()
$.each()
return
debugger // Make sure we get in here to set the value correctly
}
}

/* We value sonarjs rules enough to test them, here. Sorry for the mess. */

function shortFunction (arg) {
function shortFunction(arg) {
if (arg) {
console.log(true);
console.log(true)
}
return true;
return true
}

// sonarjs/no-identical-functions checks function bodies of three lines and above
function duplicateFunction (arg) {
function duplicateFunction(arg) {
if (arg) {
console.log(true);
console.log(true)
}
return true;
return true
}

// sonarjs/no-all-duplicated-branches
if (true) {
shortFunction();
shortFunction()
} else {
shortFunction();
shortFunction()
}

// sonarjs/max-switch-cases, sonarjs/no-duplicated-branches
switch (1) {
case 1:
break;
break
case 2:
switch (2) {
case 1:
duplicateFunction();
duplicateFunction();
break;
duplicateFunction()
duplicateFunction()
break
case 1:
duplicateFunction();
duplicateFunction();
break;
duplicateFunction()
duplicateFunction()
break
}
break;
break
case 3:
break;
break
case 4:
break;
break
case 5:
break;
break
case 6:
break;
break
case 7:
break;
break
case 8:
break;
break
case 9:
break;
break
case 10:
break;
break
case 11:
break;
break
default:
break;
break
}
Loading