Skip to content

Commit 11be3a4

Browse files
Linting overhaul (#1094)
1 parent eaf3903 commit 11be3a4

File tree

441 files changed

+2002
-3850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+2002
-3850
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11

2+
!.meta

.eslintrc

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
{
22
"root": true,
3-
"parser": "babel-eslint",
4-
"parserOptions": {
5-
"ecmaVersion": 7,
6-
"sourceType": "module"
7-
},
8-
"globals": {
9-
"BigInt": true
10-
},
3+
"extends": "@exercism/eslint-config-javascript",
114
"env": {
12-
"es6": true,
13-
"node": true,
145
"jest": true
156
},
16-
"extends": [
17-
"eslint:recommended",
18-
"plugin:import/errors",
19-
"plugin:import/warnings"
20-
],
21-
"rules": {
22-
"linebreak-style": "off",
23-
24-
"import/extensions": "off",
25-
"import/no-default-export": "off",
26-
"import/no-unresolved": "off",
27-
"import/prefer-default-export": "off"
28-
}
7+
"overrides": [
8+
{
9+
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
10+
"excludedFiles": ["custom.spec.js"],
11+
"extends": "@exercism/eslint-config-javascript/maintainers"
12+
}
13+
]
2914
}

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,26 @@ If you'd like to download [`canonical_data_syncer`][canonical-data-syncer], you
164164

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

167+
> ⚠ If you into into the following error:
168+
>
169+
> ```text
170+
> SyntaxError: Unexpected token 'export'
171+
> ```
172+
>
173+
> It's because your local node version does **not** support es6
174+
> `import` and `export` statements in regular `.js` files, or
175+
> files without extension. This is one of the reasons why these
176+
> scripts are meant to be ran through node:
177+
>
178+
> ```shell
179+
> npx babel-node scripts/the-script
180+
> ```
181+
>
182+
> Additionally, this ensures that the code written in the scripts
183+
> and their dependencies can be executed by your current node
184+
> version, which may be different than the maintainer or
185+
> contributor who contributed to the script.
186+
167187
#### `format`
168188
169189
```js

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ You can find this in the [`config.json`][file-config].
1616
See [CONTRIBUTING.md][file-contributing] for a list of requirements to contribute to this track.
1717
It also has a list of tools you can use, of which the `test` tool is one of them.
1818

19+
## Running the code quality tooling (linter)
20+
21+
This run `eslint` for all files that _require_ linting.
22+
23+
```shell
24+
npx eslint exercises/**/*.spec.js exercises/**/.meta/*.js --fix
25+
```
26+
27+
These are also the files that are linted using the lint script, mentioned in [CONTRIBUTING.md][file-contributing].
28+
The lint rules imposed on contributors and maintainers are stricter than those for the student.
29+
The idea is that we do **not** impose style rules on the students, but we guard for (potential) errors.
30+
31+
Files with strict rules:
32+
33+
- `<slug>.spec.js`
34+
- `.meta/proof.ci.js`
35+
- `.meta/exemplar.js`
36+
37+
Files with loose rules:
38+
39+
- `custom.spec.js`
40+
- `<slug>.js`
41+
1942
## Running the test suite
2043

2144
This runs `jest` tests for all sample solutions.

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
node: 'current',
88
},
99
useBuiltIns: 'entry',
10-
corejs: 3,
10+
corejs: '3.10',
1111
},
1212
],
1313
],
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
{
22
"root": true,
3-
"parser": "babel-eslint",
4-
"parserOptions": {
5-
"ecmaVersion": 7,
6-
"sourceType": "module"
7-
},
8-
"globals": {
9-
"BigInt": true
10-
},
3+
"extends": "@exercism/eslint-config-javascript",
114
"env": {
12-
"es6": true,
13-
"node": true,
145
"jest": true
156
},
16-
"extends": [
17-
"eslint:recommended",
18-
"plugin:import/errors",
19-
"plugin:import/warnings"
20-
],
21-
"rules": {
22-
"linebreak-style": "off",
23-
24-
"import/extensions": "off",
25-
"import/no-default-export": "off",
26-
"import/no-unresolved": "off",
27-
"import/prefer-default-export": "off"
28-
}
7+
"overrides": [
8+
{
9+
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
10+
"excludedFiles": ["custom.spec.js"],
11+
"extends": "@exercism/eslint-config-javascript/maintainers"
12+
}
13+
]
2914
}

exercises/concept/annalyns-infiltration/annalyns-infiltration.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import {
77

88
describe("Annalyn's infiltration", () => {
99
describe('can execute fast attack', () => {
10-
test(`when the knight is awake`, () => {
10+
test('when the knight is awake', () => {
1111
const knightIsAwake = true;
1212
const expected = false;
1313

1414
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
1515
});
1616

17-
test(`when the knight is asleep`, () => {
17+
test('when the knight is asleep', () => {
1818
const knightIsAwake = false;
1919
const expected = true;
2020

exercises/concept/annalyns-infiltration/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
node: 'current',
88
},
99
useBuiltIns: 'entry',
10-
corejs: 3,
10+
corejs: '3.10',
1111
},
1212
],
1313
],

exercises/concept/annalyns-infiltration/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"Derk-Jan Karrenbeld <[email protected]> (https://derk-jan.com)"
77
],
88
"private": true,
9+
"license": "MIT",
910
"repository": {
1011
"type": "git",
1112
"url": "https://github.com/exercism/javascript",
@@ -16,20 +17,19 @@
1617
"@babel/core": "^7.13.15",
1718
"@babel/plugin-syntax-bigint": "^7.8.3",
1819
"@babel/preset-env": "^7.13.15",
20+
"@exercism/eslint-config-javascript": "^0.3.1",
1921
"@types/jest": "^26.0.22",
2022
"@types/node": "^14.14.39",
2123
"babel-eslint": "^10.1.0",
2224
"babel-jest": "^26.6.3",
2325
"core-js": "^3.10.1",
2426
"eslint": "^7.24.0",
25-
"eslint-plugin-import": "^2.22.1",
2627
"jest": "^26.6.3"
2728
},
29+
"dependencies": {},
2830
"scripts": {
2931
"test": "jest --no-cache ./*",
3032
"watch": "jest --no-cache --watch ./*",
3133
"lint": "eslint ."
32-
},
33-
"license": "MIT",
34-
"dependencies": {}
34+
}
3535
}
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
{
22
"root": true,
3-
"parser": "babel-eslint",
4-
"parserOptions": {
5-
"ecmaVersion": 7,
6-
"sourceType": "module"
7-
},
8-
"globals": {
9-
"BigInt": true
10-
},
3+
"extends": "@exercism/eslint-config-javascript",
114
"env": {
12-
"es6": true,
13-
"node": true,
145
"jest": true
156
},
16-
"extends": [
17-
"eslint:recommended",
18-
"plugin:import/errors",
19-
"plugin:import/warnings"
20-
],
21-
"rules": {
22-
"linebreak-style": "off",
23-
24-
"import/extensions": "off",
25-
"import/no-default-export": "off",
26-
"import/no-unresolved": "off",
27-
"import/prefer-default-export": "off"
28-
}
7+
"overrides": [
8+
{
9+
"files": [".meta/proof.ci.js", ".meta/exemplar.js", "*.spec.js"],
10+
"excludedFiles": ["custom.spec.js"],
11+
"extends": "@exercism/eslint-config-javascript/maintainers"
12+
}
13+
]
2914
}

0 commit comments

Comments
 (0)