mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Fix eslint/prettier integration
This commit is contained in:
parent
a570a6bd4a
commit
ee5217a9d2
@ -8,6 +8,9 @@ charset=utf-8
|
||||
trim_trailing_whitespace=true
|
||||
insert_final_newline=true
|
||||
|
||||
[{*.js,*.jsx}]
|
||||
indent_size=2
|
||||
|
||||
[{*.yml,*.yaml}]
|
||||
indent_size=2
|
||||
|
||||
|
||||
63
.eslintrc.js
Normal file
63
.eslintrc.js
Normal file
@ -0,0 +1,63 @@
|
||||
/* eslint-disable import/no-commonjs, import/unambiguous */
|
||||
/* global module:false, __dirname:false */
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {execSync} = require('child_process');
|
||||
const _ = require('lodash');
|
||||
const resolve = require('resolve');
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
// Returns the path to the Indico source package/repo
|
||||
const PATH_COMMAND = `python -c 'from flask.helpers import get_root_path; print get_root_path("indico")'`;
|
||||
|
||||
let indicoBaseDir = null;
|
||||
const indicoPathFile = path.join(__dirname, '.indico_source');
|
||||
|
||||
// If there's an .indico_source file in the same dir, let's use it
|
||||
if (fs.existsSync(indicoPathFile)) {
|
||||
indicoBaseDir = fs
|
||||
.readFileSync(indicoPathFile)
|
||||
.toString()
|
||||
.trim();
|
||||
}
|
||||
|
||||
// Otherwise, let's use Python to figure it out
|
||||
if (!indicoBaseDir) {
|
||||
// Figure out where the Indico code base has been set up
|
||||
indicoBaseDir = path.join(
|
||||
execSync(PATH_COMMAND, {
|
||||
encoding: 'utf8',
|
||||
}).trim(),
|
||||
'..'
|
||||
);
|
||||
}
|
||||
|
||||
let currentMap = [];
|
||||
let defaultConfig = {};
|
||||
|
||||
try {
|
||||
defaultConfig = yaml.safeLoad(fs.readFileSync(path.join(indicoBaseDir, '.eslintrc.yml')));
|
||||
currentMap = defaultConfig.settings['import/resolver'].alias.map;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
const reactPath = resolve.sync('react', {basedir: indicoBaseDir});
|
||||
const react = require(reactPath);
|
||||
|
||||
module.exports = _.merge(defaultConfig, {
|
||||
settings: {
|
||||
'react': {
|
||||
version: react.version,
|
||||
},
|
||||
'import/resolver': {
|
||||
alias: {
|
||||
map: currentMap.map(([k, v]) => [k, path.resolve(indicoBaseDir, v)]),
|
||||
},
|
||||
node: {
|
||||
paths: path.join(indicoBaseDir, 'node_modules'),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
1
.prettierrc
Normal file
1
.prettierrc
Normal file
@ -0,0 +1 @@
|
||||
"eslint-config-indico/prettier-config"
|
||||
22
package.json
Normal file
22
package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "plugins",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"repository": "https://github.com/indico/indico-plugins",
|
||||
"author": "Indico Team <indico-team@cern.ch>",
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^10.0.2",
|
||||
"eslint": "^6.0.1",
|
||||
"eslint-cli": "^1.1.1",
|
||||
"eslint-config-indico": "^1.2.0",
|
||||
"eslint-config-prettier": "^6.0.0",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-plugin-babel": "^5.3.0",
|
||||
"eslint-plugin-import": "^2.18.0",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"eslint-plugin-react": "^7.14.2",
|
||||
"eslint-plugin-react-hooks": "^1.6.1",
|
||||
"lodash": "^4.17.14",
|
||||
"prettier": "^1.18.2"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user