Skip to content

wip(eslint-plugin): add new blank-line-declaration-usage rule and tests for it #713

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ function assertTasksSupported(version, tasks) {
default:
{
const message = getSupportedTasks(task)[version] || '';

if (message !== true) {
log(
colors.yellow(
Original file line number Diff line number Diff line change
@@ -438,6 +438,7 @@ it('_promptThemeSource should prompt correct workflow', () => {
prototype._promptThemeSource();

const args = inquirer.prompt.getCall(0).args;

const questions = args[0];

const extendType = questions[0];
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

expect(item.name).toBe(name);
@@ -78,6 +79,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

if (number === 1) {
@@ -93,6 +95,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

expect(!item.checked).toBe(true);
@@ -106,6 +109,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

if (number === 1) {
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ class ExtendPrompt {
const baseTheme = this.themeConfig.baseTheme;
const module = answers.module;
const modulePackages = answers.modules;

const pkg = modulePackages[module];

if (!module) {
Original file line number Diff line number Diff line change
@@ -114,9 +114,11 @@ function getLiferayThemeModuleFromURL(url) {
// Just in case package name doesn't match URL basename, read it.

const {dependencies} = JSON.parse(fs.readFileSync('package.json'));

const themeName = Object.keys(dependencies)[0];

const json = path.join('node_modules', themeName, 'package.json');

config = JSON.parse(fs.readFileSync(json));
});

@@ -183,6 +185,7 @@ module.exports = {
*/
function withScratchDirectory(cb) {
const template = path.join(os.tmpdir(), 'theme-finder-');

const directory = fs.mkdtempSync(template);

const cwd = process.cwd();
Original file line number Diff line number Diff line change
@@ -281,6 +281,7 @@ module.exports = function (options) {
.pipe(
plugins.filter((file) => {
const extname = path.extname(file.path).slice(1);

const basename = path.basename(file.path, `.${extname}`);

if (promptResults[basename][extname]) {
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ const lfrThemeConfig = require('./liferay_theme_config');
const argv = minimist(process.argv.slice(2));

const pkg = lfrThemeConfig.getConfig(true);

const themeConfig = pkg.liferayTheme;

const CUSTOM_DEP_PATH_ENV_VARIABLE_MAP = {
Original file line number Diff line number Diff line change
@@ -147,6 +147,7 @@ describe('using lib_sass', () => {

function _assertFixAtDirectives(cb) {
const cssPath = path.join(buildPath, 'css');

const mainCssPath = path.join(cssPath, 'main.css');

expect(fs.existsSync(cssPath)).toBe(true);
@@ -195,6 +196,7 @@ describe('using lib_sass', () => {
expect(fs.existsSync(templatesPath)).toBe(true);

const customCSSFileName = '_custom.scss';

const customCSSPath = path.join(cssPath, customCSSFileName);

const fileContent = testUtil.stripNewlines(
@@ -288,6 +290,7 @@ describe('using lib_sass', () => {
expect(fs.existsSync(velocityPath)).toBe(true);

const customCSSFileName = '_custom.scss';

const customCSSPath = path.join(buildPath, 'css', customCSSFileName);

expect(fs.readFileSync(customCSSPath).toString()).toMatch(
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ beforeEach(() => {
namespace: 'status_task',
registerTasks: true,
});

runSequence = config.runSequence;
});

Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ const DEPLOYMENT_STRATEGIES = themeUtil.DEPLOYMENT_STRATEGIES;

function registerTasks(options) {
const {argv, gulp, pathDist} = options;

const {storage} = gulp;

const runSequence = require('run-sequence').use(gulp);
Original file line number Diff line number Diff line change
@@ -185,8 +185,11 @@ module.exports = function (options) {

gulp.task('watch:reload', (cb) => {
const changedFile = storage.get('changedFile');

const srcPath = path.relative(process.cwd(), changedFile.path);

const dstPath = srcPath.replace(/^src\//, '');

const urlPath = `${resourcePrefix}/${distName}/${dstPath}`;

livereload.changed({
@@ -276,8 +279,10 @@ module.exports = function (options) {
const requestUrl = url.parse(req.url);

const match = themePattern.exec(requestUrl.pathname);

if (match) {
const filepath = path.resolve('build', match[3]);

const ext = path.extname(filepath);

isReadable(filepath).then((exists) => {
@@ -307,9 +312,11 @@ module.exports = function (options) {
`Watch mode is now active at: ${url}`,
`Proxying: ${proxyUrl}`,
];

const width = messages.reduce((max, line) => {
return Math.max(line.length, max);
}, 0);

const ruler = '-'.repeat(width);

// eslint-disable-next-line no-console
Original file line number Diff line number Diff line change
@@ -30,7 +30,9 @@ module.exports = class extends Generator {
const cp = new Copier(this);

const {layoutId, liferayVersion} = this.answers;

const layoutName = snakeCase(layoutId);

const templateFilename = `${layoutName}.ftl`;
const thumbnailFilename = `${layoutName}.png`;

@@ -71,6 +73,7 @@ module.exports = class extends Generator {

_getDevDependencies() {
const {liferayVersion} = this.answers;

const devDependencies = devDependenciesMap[liferayVersion].default;

return JSON.stringify(devDependencies, null, 2)
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ module.exports = class extends Generator {
const cp = new Copier(this);

const {layoutId, liferayVersion} = this.answers;

const layoutName = snakeCase(layoutId);

const templateFilename = `${layoutName}.ftl`;
const thumbnailFilename = `${layoutName}.png`;

Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ module.exports = class Copier {
*/
copyDir(src, {context = {}} = {}) {
const gen = this._generator;

const files = fs.readdirSync(gen.templatePath(src));

files.forEach((file) => {
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ class Project {

get type() {
const {fs} = this._generator;

const pkgJson = fs.readJSON('package.json');

if (pkgJson === undefined) {
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ const pipeline = promisify(stream.pipeline);

async function writing(generator, themeName) {
const project = new Project(generator);

const {liferayVersion} = project;

print(
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ module.exports.registerTasks = function (options) {

function register(options) {
const gulp = (options.gulp = plugins.help(options.gulp));

const store = gulp.storage;

store.set('changedFile');
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ describe('resolveDependency()', () => {
const resolved = util.resolveDependency(
'liferay-frontend-theme-styled'
);

expect(resolved).toContain(process.cwd());
});
});
Original file line number Diff line number Diff line change
@@ -436,6 +436,7 @@ it('_promptThemeSource should prompt correct workflow', () => {
prototype._promptThemeSource();

const args = inquirer.prompt.getCall(0).args;

const questions = args[0];

const extendType = questions[0];
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

expect(item.name).toBe(name);
@@ -78,6 +79,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

if (number === 1) {
@@ -93,6 +95,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

expect(!item.checked).toBe(true);
@@ -106,6 +109,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t

_.forEach(choices, (item, index) => {
const number = index + 1;

const name = 'themelet-' + number;

if (number === 1) {
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ class ExtendPrompt {
const baseTheme = this.themeConfig.baseTheme;
const module = answers.module;
const modulePackages = answers.modules;

const pkg = modulePackages[module];

if (!module) {
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ class URLPackagePrompt {
if (this.themelet && answers.module) {
Object.keys(answers.module).forEach((k) => {
const moduleName = this.config.selectedModules[k];

answers.module[moduleName] = answers.module[k];
delete answers.module[k];
});
Original file line number Diff line number Diff line change
@@ -26,10 +26,12 @@ module.exports = function (css, options) {

function updatePosition(str) {
var lines = str.match(/\n/g);

if (lines) {
lineno += lines.length;
}
var i = str.lastIndexOf('\n');

column = ~i ? str.length - i : column + str.length;
}

@@ -80,6 +82,7 @@ module.exports = function (css, options) {

function error(msg, start) {
var err = new Error(`${filename} (${lineno}:${column}) ${msg}`);

err.position = new Position(start);
err.filename = filename;
err.description = msg;
@@ -142,10 +145,12 @@ module.exports = function (css, options) {

function match(re) {
var m = re.exec(css);

if (!m) {
return;
}
var str = m[0];

updatePosition(str);
css = css.slice(str.length);

@@ -211,6 +216,7 @@ module.exports = function (css, options) {

function selector() {
var m = match(/^([^{]+)/);

if (!m) {
return;
}
@@ -232,6 +238,7 @@ module.exports = function (css, options) {
// prop

var prop = match(/^(\*?[-#/*\w]+(\[[0-9a-z_-]+\])?)\s*/);

if (!prop) {
return;
}
@@ -246,6 +253,7 @@ module.exports = function (css, options) {
// val

var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/);

if (!val) {
return error('property missing value');
}
@@ -462,6 +470,7 @@ module.exports = function (css, options) {
function atpage() {
var pos = position();
var m = match(/^@page */);

if (!m) {
return;
}
@@ -499,6 +508,7 @@ module.exports = function (css, options) {
function atdocument() {
var pos = position();
var m = match(/^@([-\w]+)?document *([^{]+)/);

if (!m) {
return;
}
@@ -585,10 +595,12 @@ module.exports = function (css, options) {
function _atrule(name) {
var pos = position();
var m = match(new RegExp('^@' + name + ' *([^;\\n]+);'));

if (!m) {
return;
}
var ret = {type: name};

ret[name] = trim(m[1]);

return pos(ret);
Loading