diff --git a/index.js b/index.js index 7702693..b0cc55a 100644 --- a/index.js +++ b/index.js @@ -26,5 +26,9 @@ module.exports = { named: 'never', asyncArrow: 'always', }], + 'quotes': ['error', 'single', 'avoid-escape'], + 'lines-between-class-members': ['error', 'always', { + exceptAfterSingleLine: true, + }], }, }; diff --git a/tests/files/lines-between-class-members-bad.js b/tests/files/lines-between-class-members-bad.js new file mode 100644 index 0000000..f57af36 --- /dev/null +++ b/tests/files/lines-between-class-members-bad.js @@ -0,0 +1,11 @@ +class Example { + constructor() { + console.log(); + } + // there should be a line between class members + method() { + console.log(); + } +} + +console.log((new Example()).theAnswer); diff --git a/tests/files/lines-between-class-members-good.js b/tests/files/lines-between-class-members-good.js new file mode 100644 index 0000000..b0c5aa3 --- /dev/null +++ b/tests/files/lines-between-class-members-good.js @@ -0,0 +1,16 @@ +class Example { + constructor() { + console.log(); + } + + // no line between one-line class members is OK + get theAnswer() { return 42; } + get message() { return 'hi'; } + + // method() is unused but sadly the linter doesn't catch it yet + method() { + console.log(); + } +} + +console.log((new Example()).theAnswer); diff --git a/tests/files/quotes-1-bad.js b/tests/files/quotes-1-bad.js new file mode 100644 index 0000000..b931aca --- /dev/null +++ b/tests/files/quotes-1-bad.js @@ -0,0 +1 @@ +console.log("no double quotes unless there is an apostrophe there"); diff --git a/tests/files/quotes-2-bad.js b/tests/files/quotes-2-bad.js new file mode 100644 index 0000000..d5f2522 --- /dev/null +++ b/tests/files/quotes-2-bad.js @@ -0,0 +1 @@ +console.log(`no backticks without parameters`); diff --git a/tests/files/quotes-good.js b/tests/files/quotes-good.js new file mode 100644 index 0000000..5e16e0b --- /dev/null +++ b/tests/files/quotes-good.js @@ -0,0 +1,4 @@ +console.log('single quotes OK'); +console.log("double quotes OK only if there's an apostrophe in them"); +console.log('backslash \' quoting allowed'); +console.log(`backticks OK with at least ${1} parameters`);