Skip to content

Upgrade eslint and extract config #645

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 3 commits into from
Mar 25, 2019
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
26 changes: 26 additions & 0 deletions .eslintrc
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"
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
64 changes: 64 additions & 0 deletions bin/tools/copy-eslint-config
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);
}
26 changes: 26 additions & 0 deletions exercises/accumulate/.eslintrc
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"
}
}
24 changes: 2 additions & 22 deletions exercises/accumulate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"@babel/preset-env": "^7.4.2",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"eslint": "^5.12.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint": "^5.15.3",
"eslint-plugin-import": "^2.16.0",
"jest": "^24.5.0"
},
"jest": {
Expand All @@ -30,25 +29,6 @@
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb-base",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off",
"import/prefer-default-export": "off",
"import/no-default-export": "off"
}
},
"license": "MIT",
"dependencies": {}
}
26 changes: 26 additions & 0 deletions exercises/acronym/.eslintrc
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"
}
}
24 changes: 2 additions & 22 deletions exercises/acronym/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"@babel/preset-env": "^7.4.2",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"eslint": "^5.12.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint": "^5.15.3",
"eslint-plugin-import": "^2.16.0",
"jest": "^24.5.0"
},
"jest": {
Expand All @@ -30,25 +29,6 @@
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb-base",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off",
"import/prefer-default-export": "off",
"import/no-default-export": "off"
}
},
"license": "MIT",
"dependencies": {}
}
26 changes: 26 additions & 0 deletions exercises/all-your-base/.eslintrc
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"
}
}
24 changes: 2 additions & 22 deletions exercises/all-your-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"@babel/preset-env": "^7.4.2",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"eslint": "^5.12.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint": "^5.15.3",
"eslint-plugin-import": "^2.16.0",
"jest": "^24.5.0"
},
"jest": {
Expand All @@ -30,25 +29,6 @@
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb-base",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off",
"import/prefer-default-export": "off",
"import/no-default-export": "off"
}
},
"license": "MIT",
"dependencies": {}
}
26 changes: 26 additions & 0 deletions exercises/allergies/.eslintrc
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"
}
}
24 changes: 2 additions & 22 deletions exercises/allergies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"@babel/preset-env": "^7.4.2",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"eslint": "^5.12.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint": "^5.15.3",
"eslint-plugin-import": "^2.16.0",
"jest": "^24.5.0"
},
"jest": {
Expand All @@ -30,25 +29,6 @@
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb-base",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off",
"import/prefer-default-export": "off",
"import/no-default-export": "off"
}
},
"license": "MIT",
"dependencies": {}
}
26 changes: 26 additions & 0 deletions exercises/alphametics/.eslintrc
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"
}
}
Loading