-
-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade eslint and extract config (#645)
* Upgrade eslint and extract config - upgrade eslint to 5.15.3 - upgrade eslint-plugin-import to 2.16.0 - correctly use the import plugin - remove linebreak-style (fixes #502) - use eslint:recommended (fixes #589, fixes #480) In a later change we should turn on airbnb-base for maintaining via a script that switches this. In a later change, we should turn on several rules that guard against potential bugs, such as `no-shadow` `no-undefined` `no-var`; additionally we can add stylistic consistency without forcing style choises such as consistent spacing (but not required). * Saving files before refreshing line endings * Normalize all the line endings
- Loading branch information
1 parent
d209ecf
commit b91ba55
Showing
207 changed files
with
3,131 additions
and
2,549 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
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 @@ | ||
* text=auto |
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,64 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* This copies the current .eslintrc to a specific exercise folder or to all | ||
* of them if an exercise folder is not given. Merges the version field in case | ||
* it's set. | ||
* | ||
* Usage: | ||
* | ||
* ./bin/tools/copy-eslint-config <exercise> | ||
*/ | ||
|
||
// @ts-check | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const ROOT_PATH = path.join(__dirname, '..', '..'); | ||
const BABEL_CONFIG_PATH = path.join(ROOT_PATH, '.eslintrc'); | ||
const EXERCISE = process.argv.slice(2).find(arg => !arg.startsWith('-')); | ||
|
||
process.stdout.write(`=> copy eslint config for ${EXERCISE || 'all exercises'}\n`); | ||
|
||
|
||
function execute(exercise) { | ||
const EXERCISE_DIR = path.join(ROOT_PATH, 'exercises', exercise); | ||
const destination = path.join(EXERCISE_DIR, path.basename(BABEL_CONFIG_PATH)); | ||
|
||
fs.copyFile(BABEL_CONFIG_PATH, destination, (err) => { | ||
if (err) { | ||
process.stderr.write(`=> error for ${exercise}: ${err.message}\n`); | ||
} else { | ||
process.stdout.write(`=> copied eslint config to ${exercise}\n`); | ||
} | ||
}); | ||
|
||
} | ||
|
||
if (!EXERCISE) { | ||
process.stdin.resume(); | ||
process.stdout.write('?> are you sure? [Y/n]\n'); | ||
process.stdin.once('data', (data) => { | ||
process.stdin.pause(); | ||
|
||
const input = data.toString().trim(); | ||
|
||
if (!/^(?:\s?|y|yes)$/i.test(input)) { | ||
process.stdout.write('=> ok bye\n'); | ||
process.exit(0); | ||
return; | ||
} | ||
|
||
fs.readdir(path.join(ROOT_PATH, 'exercises'), (err, exercises) => { | ||
if (err) { | ||
process.stderr.write(err.message); | ||
process.exit(-1); | ||
} | ||
|
||
exercises.forEach(execute); | ||
}); | ||
}); | ||
} else { | ||
execute(EXERCISE); | ||
} |
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,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
Oops, something went wrong.