Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// 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: [
'frontier',
'./index.js',
'plugin:eslint-plugin-sonarjs/recommended'
'eslint-config-frontier',
'plugin:eslint-plugin-sonarjs/recommended',
'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-sonarjs'
'eslint-plugin-no-only-tests',
'eslint-plugin-no-skip-tests',
'eslint-plugin-sonarjs',
'eslint-plugin-test-selectors' // NOTE: Only runs against JSX
],
rules: {
'deprecate/function': ['error',
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,36 @@ Utilizes 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/benmosher/eslint-plugin-import)
- [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)
- [eslint-plugin-json](https://github.com/azeemba/eslint-plugin-json)
- [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node)
- [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
- [eslint-plugin-no-skip-tests](https://github.com/romaingaillardjs/eslint-plugin-no-skip-tests)
- [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?):

> - 'eslint-plugin-i18next' // SEEMS LIKE TOO MANY FALSE POSITIVES
> - 'eslint-plugin-json-format' // DOESN'T SEEM TO WORK
> - 'eslint-plugin-package-json' // undefined TypeErrors while parsing package.json
> - 'eslint-plugin-sort-keys-fix' // RUINS INDENTATION, DOES NOT BRING JSDOCS ALONG

![alt text](demo/example-eslint-results.png "Example linting infractions for things the Tree team cares about")

## Usage:

1. Add either `eslint-config-tree` or `eslint-config-frontier-react` as a devDependency.
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:^1",
> "eslint-config-tree": "github:fs-webdev/eslint-config-tree#semver:^2",

1. In your `eslintrc.js` file, put the following:
<pre><code>module.exports = {
extends: [
'frontier',
'tree'
'eslint-config-frontier', // or '@fs/eslint-config-frontier-react'
'eslint-config-tree'
],
plugins: [
'eslint-plugin-bestpractices',
Expand Down
2 changes: 1 addition & 1 deletion demo/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM (params) {

let variable = (true) ? true : true;

if (window === undefined && window === undefined) {
if (window === undefined && window === undefined && true === params) {
ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM('a', 'b');
const deprecatedImport = require('path/to/legacyModule');
deprecatedImport.execute();
Expand Down
14 changes: 14 additions & 0 deletions demo/example.test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
var chai = require('chai');
var assert = chai.assert;

describe.only('example.test.js', () => {
it.only('should pass', () => {
assert.true(true);
});

it.skip('should pass', () => {
assert.true(true);
});
});
</script>
4 changes: 2 additions & 2 deletions demo/test/lint-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ test('Should have consistent rule output', async t => {
return fileManager.readFile('./demo/test/snapshots/new-lint-results.txt')
.then((content) => {
const eslintOutput = content.toString(); // content is instance of Buffer, so it needs to be parsed
t.snapshot(eslintOutput);
return t.snapshot(eslintOutput);
})
.catch((err) => {
console.log(err);
t.fail();
return t.fail();
});
});
22 changes: 15 additions & 7 deletions demo/test/snapshots/lint-output.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Generated by [AVA](https://ava.li).
> Snapshot 1

`␊
example.test.html␊
5:12 error describe.only not permitted no-only-tests/no-only-tests␊
6:8 error it.only not permitted no-only-tests/no-only-tests␊
10:8 warning it.skip not permitted no-skip-tests/no-skip-tests␊
example.js␊
6:0 warning Inline eslint-disable found bestpractices/no-eslint-disable␊
8:1 warning Unexpected 'FIXME' comment no-warning-comments␊
Expand All @@ -18,25 +23,27 @@ Generated by [AVA](https://ava.li).
21:1 warning Missing JSDoc @description declaration jsdoc/require-description␊
21:1 warning JSDoc @returns declaration present but return expression not available in function jsdoc/require-returns-check␊
21:1 warning JSDoc syntax error valid-jsdoc␊
23:0 warning Expected @param names to be "params". Got "a, b" jsdoc/check-param-names␊
23:0 warning Missing JSDoc @param "a" description jsdoc/require-param-description␊
24:0 warning Missing JSDoc @param "b" type jsdoc/require-param-type
23:0 warning Expected @param names to be "params". Got "a, b" jsdoc/check-param-names
24:0 warning Missing JSDoc @param "b" description jsdoc/require-param-description␊
24:0 warning Missing JSDoc @param "b" type jsdoc/require-param-type␊
25:0 warning Missing JSDoc @returns type jsdoc/require-returns-type␊
25:0 warning Missing JSDoc @returns description jsdoc/require-returns-description␊
30:5 error 'variable' is assigned a value but never used no-unused-vars␊
30:16 error This conditional operation returns the same value whether the condition is "true" or "false" sonarjs/no-all-duplicated-branches␊
30:16 warning This conditional operation returns the same value whether the condition is "true" or "false" sonarjs/no-all-duplicated-branches␊
30:17 error Unexpected constant condition no-constant-condition␊
30:25 error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary␊
32:5 error Correct one of the identical sub-expressions on both sides of operator "&&" sonarjs/no-identical-expressions␊
32:5 warning Correct one of the identical sub-expressions on both sides of operator "&&" sonarjs/no-identical-expressions␊
32:16 warning Unexpected use of undefined no-undefined␊
32:40 warning Unexpected use of undefined no-undefined␊
33:3 error This function expects 1 argument, but 2 were provided sonarjs/no-extra-arguments␊
32:53 error Expected literal to be on the right side of === yoda␊
32:62 error 'params' is not defined no-undef␊
33:3 warning This function expects 1 argument, but 2 were provided sonarjs/no-extra-arguments␊
34:28 error Module path/to/legacyModule is deprecated. Use module x instead deprecate/import␊
36:3 error Function deprecatedFunction is deprecated. Use function x from package y instead deprecate/function␊
36:3 error 'deprecatedFunction' is not defined no-undef␊
37:3 error '$' is not defined no-undef␊
37:3 error Member expression $.each is deprecated. Use native forEach instead deprecate/member-expression␊
37:3 error '$' is not defined no-undef␊
38:3 error Unexpected 'debugger' statement no-debugger␊
example.json␊
Expand All @@ -48,5 +55,6 @@ Generated by [AVA](https://ava.li).
6:19 error Trailing comma json/trailingcomma␊
8:2 error End of file expected json/undefined␊
✖ 35 problems (18 errors, 17 warnings)␊
✖ 40 problems (19 errors, 21 warnings)␊
1 error and 0 warnings potentially fixable with the `--fix` option.␊
`
Binary file modified demo/test/snapshots/lint-output.js.snap
Binary file not shown.
21 changes: 18 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
extends: [
'eslint-config-standard'
'eslint-config-standard',
'plugin:promise/recommended'
// '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.
],
env: {
Expand Down Expand Up @@ -48,7 +49,10 @@ module.exports = {
'eslint-plugin-html',
'eslint-plugin-jsdoc',
'eslint-plugin-json'
// 'eslint-plugin-sonarjs'
// 'eslint-plugin-no-only-tests',
// 'eslint-plugin-no-skip-tests',
// 'eslint-plugin-sonarjs',
// 'eslint-plugin-test-selectors' // NOTE: Only runs against JSX
],
/**
* @property rules - Tree custom rule and additional linter configuration.
Expand Down Expand Up @@ -95,6 +99,9 @@ module.exports = {

'bestpractices/no-eslint-disable': 'warn',

'no-only-tests/no-only-tests': 'error',
'no-skip-tests/no-skip-tests': 'warn',

'sonarjs/cognitive-complexity': 'warn',
'sonarjs/max-switch-cases': 'warn',
'sonarjs/no-all-duplicated-branches': 'warn',
Expand All @@ -114,7 +121,15 @@ module.exports = {
'sonarjs/prefer-immediate-return': 'warn',
'sonarjs/prefer-object-literal': 'warn',
'sonarjs/prefer-single-boolean-return': 'warn',
'sonarjs/prefer-while': 'warn'
'sonarjs/prefer-while': 'warn',

'test-selectors/anchor': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
'test-selectors/button': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
'test-selectors/input': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
'test-selectors/onChange': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
'test-selectors/onClick': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
'test-selectors/onKeyDown': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }],
'test-selectors/onKeyUp': ['warn', 'always', { 'ignoreDisabled': false, 'ignoreReadonly': false }]

// See eslint-config-tree/.eslintrc.js for example deprecation rules.
}
Expand Down
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-tree",
"version": "1.0.15",
"version": "2.0.0",
"description": "Shared Tree configuration that contains overrides and enhancements on top of the base frontier configuration.",
"main": "index.js",
"repository": {
Expand All @@ -23,30 +23,37 @@
},
"dependencies": {
"babel-eslint": "^8",
"eslint": "^5",
"eslint-config-standard": "^12",
"eslint": "^6",
"eslint-config-standard-react": "^7",
"eslint-config-standard": "^12",
"eslint-plugin-bestpractices": "git+https://github.com/skye2k2/eslint-plugin-bestpractices.git",
"eslint-plugin-deprecate": "^0.5",
"eslint-plugin-html": "^6",
"eslint-plugin-import": "^2",
"eslint-plugin-jsdoc": "8.3.0",
"eslint-plugin-json": "^1",
"eslint-plugin-no-only-tests": "^2",
"eslint-plugin-no-skip-tests": "^1",
"eslint-plugin-node": "^9",
"eslint-plugin-promise": "^4",
"eslint-plugin-sonarjs": "^0.3",
"eslint-plugin-standard": "^4"
"eslint-plugin-standard": "^4",
"eslint-plugin-test-selectors": "^1"
},
"devDependencies": {
"ava": "^2.4.0",
"eslint-config-frontier": "github:fs-webdev/eslint-config-frontier",
"file-manager-js": "^3.1.6"
},
"resolutions": {
"eslint": "^6"
},
"scripts": {
"lint": "eslint --ignore-pattern '.*' '**/*.js' '**/*.json'",
"lint:fix": "eslint --ignore-pattern '.*' '**/*.js' '**/*.json' --fix",
"lint:report": "eslint --ignore-pattern '.*' '**/*.js' '**/*.json' '**/*.html' --format html --output-file ./reports/linter/lintresults.html & eslint --ignore-pattern '.*' '**/*.js' '**/*.json' --format json --output-file ./reports/linter/lintresults.json",
"lint:snapshot": "eslint --ignore-pattern '.*' '**/*.js' '**/*.json' --no-color --output-file ./demo/test/snapshots/new-lint-results.txt; npm run test:format",
"lint": "eslint --ignore-pattern '.*' '**/*.html' '**/*.js' '**/*.json'",
"lint:fix": "eslint --ignore-pattern '.*' '**/*.html' '**/*.js' '**/*.json' --fix",
"lint:quiet": "eslint --ignore-pattern '.*' '**/*.html' '**/*.js' '**/*.json' --quiet",
"lint:report": "eslint --ignore-pattern '.*' '**/*.html' '**/*.js' '**/*.json' '**/*.html' --format html --output-file ./reports/linter/lintresults.html & eslint --ignore-pattern '.*' '**/*.js' '**/*.json' --format json --output-file ./reports/linter/lintresults.json",
"lint:snapshot": "eslint --ignore-pattern '.*' '**/*.html' '**/*.js' '**/*.json' --no-color --output-file ./demo/test/snapshots/new-lint-results.txt; npm run test:format",
"preinstall": "git config --global url.https://github.com/.insteadOf git://github.com/",
"test": "npm run lint:snapshot; ava",
"test:format": "sed -i '' 's|^.*eslint-config-tree/demo/||g' demo/test/snapshots/new-lint-results.txt",
Expand Down