Skip to content
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

Linting overhaul #1094

Merged
merged 11 commits into from
Apr 16, 2021
Merged
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

!.meta
31 changes: 8 additions & 23 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"extends": "@exercism/eslint-config-javascript",
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"rules": {
"linebreak-style": "off",

"import/extensions": "off",
"import/no-default-export": "off",
"import/no-unresolved": "off",
"import/prefer-default-export": "off"
}
"overrides": [
{
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
"excludedFiles": ["custom.spec.js"],
"extends": "@exercism/eslint-config-javascript/maintainers"
}
]
}
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,26 @@ If you'd like to download [`canonical_data_syncer`][canonical-data-syncer], you

We have various `scripts` for you in order to aid with maintaining and contributing to this repository.

> ⚠ If you into into the following error:
>
> ```text
> SyntaxError: Unexpected token 'export'
> ```
>
> It's because your local node version does **not** support es6
> `import` and `export` statements in regular `.js` files, or
> files without extension. This is one of the reasons why these
> scripts are meant to be ran through node:
>
> ```shell
> npx babel-node scripts/the-script
> ```
>
> Additionally, this ensures that the code written in the scripts
> and their dependencies can be executed by your current node
> version, which may be different than the maintainer or
> contributor who contributed to the script.

#### `format`

```js
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ You can find this in the [`config.json`][file-config].
See [CONTRIBUTING.md][file-contributing] for a list of requirements to contribute to this track.
It also has a list of tools you can use, of which the `test` tool is one of them.

## Running the code quality tooling (linter)

This run `eslint` for all files that _require_ linting.

```shell
npx eslint exercises/**/*.spec.js exercises/**/.meta/*.js --fix
```

These are also the files that are linted using the lint script, mentioned in [CONTRIBUTING.md][file-contributing].
The lint rules imposed on contributors and maintainers are stricter than those for the student.
The idea is that we do **not** impose style rules on the students, but we guard for (potential) errors.

Files with strict rules:

- `<slug>.spec.js`
- `.meta/proof.ci.js`
- `.meta/exemplar.js`

Files with loose rules:

- `custom.spec.js`
- `<slug>.js`

## Running the test suite

This runs `jest` tests for all sample solutions.
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
node: 'current',
},
useBuiltIns: 'entry',
corejs: 3,
corejs: '3.10',
},
],
],
Expand Down
31 changes: 8 additions & 23 deletions exercises/concept/annalyns-infiltration/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"extends": "@exercism/eslint-config-javascript",
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"rules": {
"linebreak-style": "off",

"import/extensions": "off",
"import/no-default-export": "off",
"import/no-unresolved": "off",
"import/prefer-default-export": "off"
}
"overrides": [
{
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
"excludedFiles": ["custom.spec.js"],
"extends": "@exercism/eslint-config-javascript/maintainers"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {

describe("Annalyn's infiltration", () => {
describe('can execute fast attack', () => {
test(`when the knight is awake`, () => {
test('when the knight is awake', () => {
const knightIsAwake = true;
const expected = false;

expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
});

test(`when the knight is asleep`, () => {
test('when the knight is asleep', () => {
const knightIsAwake = false;
const expected = true;

Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/annalyns-infiltration/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
node: 'current',
},
useBuiltIns: 'entry',
corejs: 3,
corejs: '3.10',
},
],
],
Expand Down
8 changes: 4 additions & 4 deletions exercises/concept/annalyns-infiltration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"Derk-Jan Karrenbeld <[email protected]> (https://derk-jan.com)"
],
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/exercism/javascript",
Expand All @@ -16,20 +17,19 @@
"@babel/core": "^7.13.15",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.13.15",
"@exercism/eslint-config-javascript": "^0.3.1",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.39",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"core-js": "^3.10.1",
"eslint": "^7.24.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3"
},
"dependencies": {},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint ."
},
"license": "MIT",
"dependencies": {}
}
}
31 changes: 8 additions & 23 deletions exercises/concept/array-loops/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"extends": "@exercism/eslint-config-javascript",
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"rules": {
"linebreak-style": "off",

"import/extensions": "off",
"import/no-default-export": "off",
"import/no-unresolved": "off",
"import/prefer-default-export": "off"
}
"overrides": [
{
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
"excludedFiles": ["custom.spec.js"],
"extends": "@exercism/eslint-config-javascript/maintainers"
}
]
}
4 changes: 3 additions & 1 deletion exercises/concept/array-loops/.meta/exemplar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
export function cardTypeCheck(stack, card) {
let count = 0;

stack.forEach((c) => c === card && count++);
stack.forEach((c) => {
c === card && count++;
});

return count;
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/array-loops/array-loops.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
determineUniqueCards,
determineOddEvenCards,
cardTypeCheck,
} from './array-loops.js';
} from './array-loops';

/**
* @template T the expected return type
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/array-loops/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
node: 'current',
},
useBuiltIns: 'entry',
corejs: 3,
corejs: '3.10',
},
],
],
Expand Down
8 changes: 4 additions & 4 deletions exercises/concept/array-loops/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Exercism concept exercise on array-loops",
"author": "Derk-Jan Karrenbeld <[email protected]>",
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/exercism/javascript"
Expand All @@ -12,20 +13,19 @@
"@babel/core": "^7.13.15",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.13.15",
"@exercism/eslint-config-javascript": "^0.3.1",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.39",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"core-js": "^3.10.1",
"eslint": "^7.24.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3"
},
"dependencies": {},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint ."
},
"license": "MIT",
"dependencies": {}
}
}
31 changes: 8 additions & 23 deletions exercises/concept/bird-watcher/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"extends": "@exercism/eslint-config-javascript",
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"rules": {
"linebreak-style": "off",

"import/extensions": "off",
"import/no-default-export": "off",
"import/no-unresolved": "off",
"import/prefer-default-export": "off"
}
"overrides": [
{
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
"excludedFiles": ["custom.spec.js"],
"extends": "@exercism/eslint-config-javascript/maintainers"
}
]
}
2 changes: 1 addition & 1 deletion exercises/concept/bird-watcher/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
node: 'current',
},
useBuiltIns: 'entry',
corejs: 3,
corejs: '3.10',
},
],
],
Expand Down
6 changes: 1 addition & 5 deletions exercises/concept/bird-watcher/bird-watcher.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
totalBirdCount,
birdsInWeek,
fixBirdCountLog,
} from './bird-watcher.js';
import { totalBirdCount, birdsInWeek, fixBirdCountLog } from './bird-watcher';

describe('bird watcher', () => {
describe('totalBirdCount', () => {
Expand Down
8 changes: 4 additions & 4 deletions exercises/concept/bird-watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Exercism concept exercise on for loops and the increment and decrement operators",
"author": "Franziska Obbarius <[email protected]>",
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/exercism/javascript",
Expand All @@ -13,20 +14,19 @@
"@babel/core": "^7.13.15",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.13.15",
"@exercism/eslint-config-javascript": "^0.3.1",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.39",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"core-js": "^3.10.1",
"eslint": "^7.24.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3"
},
"dependencies": {},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint ."
},
"license": "MIT",
"dependencies": {}
}
}
Loading