Skip to content
Closed
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
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.min.*
src/lib/markbind/src/lib/markdown-it/*

!.eslintrc.js
.eslintrc.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting this file is intentional. It is ignored by default, so this line would be redundant anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this line npm run lint seems to be picking up .eslintrc.js on my machine, not sure why it doesn't seem to be consistent.

83 changes: 37 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,46 @@
/* eslint quotes: ["error", "double"] */

module.exports = {
"env": {
"node": true,
"es6": true,
"jest": true,
env: {
node: true,
es6: true,
jest: true,
},
"plugins": ["lodash"],
"extends": ["airbnb-base", "plugin:lodash/recommended"],
"rules": {
"array-bracket-newline": ["error", { "multiline": true }],
"func-names": "off",
"no-underscore-dangle": "off",
"function-paren-newline": "off",
"indent": [
"error",
2,
{
"CallExpression": { "arguments": "first" },
"FunctionDeclaration": { "parameters": "first" },
"FunctionExpression": { "parameters": "first" },
},
],
"lodash/prefer-lodash-method": [0],
"lodash/prefer-noop": [0],
"max-len": ["error", { "code": 110 }],
"operator-linebreak": ["error", "before"],
plugins: ['lodash', 'prettier'],
extends: ['airbnb-base', 'plugin:lodash/recommended', 'prettier'],
rules: {
'func-names': 'off',
'function-paren-newline': 'off',
'lodash/prefer-lodash-method': [0],
'lodash/prefer-noop': [0],
'max-len': ['error', { code: 110 }],
'no-underscore-dangle': 'off',
'prettier/prettier': 'error',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid changing formatting and config in the same commit unless syncing configs.
Also, this violates the Eslint rule overrides at the top of the file.

I kept double quotes as their documentation uses that and many projects do too, so it's easier to copy rules as-is.

// override airbnb-base dev dependencies, latest version does not white list __mocks__
"import/no-extraneous-dependencies": [
"error", {
"devDependencies": [
"test/**", // tape, common npm pattern
"tests/**", // also common npm pattern
"spec/**", // mocha, rspec-like pattern
"**/__tests__/**", // jest pattern
"**/__mocks__/**", // jest pattern
"test.{js,jsx}", // repos with a single test file
"test-*.{js,jsx}", // repos with multiple top-level test files
"**/*.{test,spec}.{js,jsx}", // tests where the extension denotes that it is a test
"**/jest.config.js", // jest config
"**/webpack.config.js", // webpack config
"**/webpack.config.*.js", // webpack config
"**/rollup.config.*.js", // rollup config
"**/rollup.config.*.js", // rollup config
"**/gulpfile.js", // gulp config
"**/gulpfile.*.js", // gulp config
"**/Gruntfile{,.js}", // grunt config
"**/protractor.conf.js", // protractor config
"**/protractor.conf.*.js", // protractor config
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'test/**', // tape, common npm pattern
'tests/**', // also common npm pattern
'spec/**', // mocha, rspec-like pattern
'**/__tests__/**', // jest pattern
'**/__mocks__/**', // jest pattern
'test.{js,jsx}', // repos with a single test file
'test-*.{js,jsx}', // repos with multiple top-level test files
'**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test
'**/jest.config.js', // jest config
'**/webpack.config.js', // webpack config
'**/webpack.config.*.js', // webpack config
'**/rollup.config.*.js', // rollup config
'**/rollup.config.*.js', // rollup config
'**/gulpfile.js', // gulp config
'**/gulpfile.*.js', // gulp config
'**/Gruntfile{,.js}', // grunt config
'**/protractor.conf.js', // protractor config
'**/protractor.conf.*.js', // protractor config
],
"optionalDependencies": false,
optionalDependencies: false,
},
],
},
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "all",
"singleQuote": true
}
129 changes: 67 additions & 62 deletions __mocks__/fs-extra-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { fs, vol } = require('memfs');
*/
function rimraf(dirPath) {
if (fs.existsSync(dirPath)) {
fs.readdirSync(dirPath).forEach((entry) => {
fs.readdirSync(dirPath).forEach(entry => {
const entryPath = path.join(dirPath, entry);
if (fs.lstatSync(entryPath).isDirectory()) {
rimraf(entryPath);
Expand All @@ -31,9 +31,8 @@ function rimraf(dirPath) {
*/
function createDir(pathArg) {
const { dir, ext } = path.parse(pathArg);
const dirNames = (ext === '')
? pathArg.split(path.sep)
: dir.split(pathArg.sep);
const dirNames =
ext === '' ? pathArg.split(path.sep) : dir.split(pathArg.sep);

dirNames.reduce((accumDir, currentdir) => {
const jointDir = path.join(accumDir, currentdir);
Expand All @@ -60,7 +59,7 @@ function copyFileSync(src, dest) {
function copyDirSync(src, dest) {
if (fs.lstatSync(src).isDirectory()) {
const files = fs.readdirSync(src);
files.forEach((file) => {
files.forEach(file => {
const curSource = path.join(src, file);
const curDest = path.join(dest, file);
if (fs.lstatSync(curSource).isDirectory()) {
Expand Down Expand Up @@ -90,7 +89,7 @@ fs.outputFileSync = (file, data) => {
/**
* Mocking fs-extra#emptydirSync
*/
fs.emptydirSync = (dir) => {
fs.emptydirSync = dir => {
if (!fs.existsSync(dir)) {
createDir(dir);
} else {
Expand All @@ -114,7 +113,6 @@ fs.copySync = (src, dest) => {
*/
fs.readJsonSync = filePath => JSON.parse(fs.readFileSync(filePath, 'utf8'));


/**
* Mocking fs-extra#outputJsonSync
*/
Expand All @@ -125,62 +123,67 @@ fs.outputJsonSync = (file, jsonData) => {
/**
* Mocking fs-extra-promise#removeAsync
*/
fs.removeAsync = pathArg => new Promise((resolve, reject) => {
try {
if (fs.lstatSync(pathArg).isDirectory()) {
rimraf(pathArg);
} else {
fs.unlinkSync(pathArg);
fs.removeAsync = pathArg =>
new Promise((resolve, reject) => {
try {
if (fs.lstatSync(pathArg).isDirectory()) {
rimraf(pathArg);
} else {
fs.unlinkSync(pathArg);
}
resolve();
} catch (err) {
reject(err);
}
resolve();
} catch (err) {
reject(err);
}
});
});

/**
* Mocking fs-extra-promise#copyAsync
*/
fs.copyAsync = (src, dest) => new Promise((resolve, reject) => {
try {
fs.copySync(src, dest);
resolve();
} catch (err) {
reject(err);
}
});
fs.copyAsync = (src, dest) =>
new Promise((resolve, reject) => {
try {
fs.copySync(src, dest);
resolve();
} catch (err) {
reject(err);
}
});

/**
* Mocking fs-extra-promise#accessAsync
*/
fs.accessAsync = pathArg => new Promise((resolve, reject) => {
try {
fs.accessSync(pathArg);
resolve();
} catch (err) {
reject(err);
}
});
fs.accessAsync = pathArg =>
new Promise((resolve, reject) => {
try {
fs.accessSync(pathArg);
resolve();
} catch (err) {
reject(err);
}
});

/**
* Mocking fs-extra-promise#outputFileAsync
*/
fs.outputFileAsync = (file, data) => new Promise((resolve, reject) => {
try {
fs.outputFileSync(file, data);
resolve();
} catch (err) {
reject(err);
}
});
fs.outputFileAsync = (file, data) =>
new Promise((resolve, reject) => {
try {
fs.outputFileSync(file, data);
resolve();
} catch (err) {
reject(err);
}
});

/**
* Mocking fs-extra-promise#mkdirp
*/
fs.mkdirp = dir => new Promise((resolve) => {
createDir(dir);
resolve();
});
fs.mkdirp = dir =>
new Promise(resolve => {
createDir(dir);
resolve();
});

/**
* Mocking fs-extra#copySync
Expand All @@ -196,25 +199,27 @@ fs.copySync = (src, dest) => {
/**
* Mocking fs-extra-promise#outputJsonAsync
*/
fs.outputJsonAsync = (file, jsonData) => new Promise((resolve, reject) => {
try {
fs.outputJsonSync(file, jsonData);
resolve();
} catch (err) {
reject(err);
}
});
fs.outputJsonAsync = (file, jsonData) =>
new Promise((resolve, reject) => {
try {
fs.outputJsonSync(file, jsonData);
resolve();
} catch (err) {
reject(err);
}
});

/**
* Mocking fs-extra-promise#readJsonAsync
* Mocking fs-extra-promise#readJsonAsync
*/
fs.readJsonAsync = filePath => new Promise((resolve, reject) => {
try {
resolve(fs.readJsonSync(filePath));
} catch (err) {
reject(err);
}
});
fs.readJsonAsync = filePath =>
new Promise((resolve, reject) => {
try {
resolve(fs.readJsonSync(filePath));
} catch (err) {
reject(err);
}
});

fs.vol = vol;
module.exports = fs;
Loading