eslint-plugin-format-lua
Version:
��# e s l i n t - p l u g i n - f o r m a t - l u a
89 lines (82 loc) • 1.95 kB
JavaScript
;
const _parserPlain = require('eslint-parser-plain');
const stylua$1 = require('@isentinel/stylua');
const eslintFormattingReporter = require('eslint-formatting-reporter');
function _interopNamespaceCompat(e) {
if (e && typeof e === 'object' && 'default' in e) return e;
const n = Object.create(null);
if (e) {
for (const k in e) {
n[k] = e[k];
}
}
n.default = e;
return n;
}
const _parserPlain__namespace = /*#__PURE__*/_interopNamespaceCompat(_parserPlain);
const stylua = {
create(context) {
const config = stylua$1.Config.new();
const range = stylua$1.Range.from_values();
return {
Program() {
const sourceCode = context.sourceCode.text;
try {
const formatted = stylua$1.formatCode(
sourceCode,
config,
range,
stylua$1.OutputVerification.None
);
eslintFormattingReporter.reportDifferences(context, sourceCode, formatted);
} catch (err) {
console.log(err);
context.report({
loc: {
end: { column: 0, line: 1 },
start: { column: 0, line: 1 }
},
message: "Failed to format the code"
});
}
}
};
},
meta: {
docs: {
category: "Stylistic",
description: "Use stylua to format lua files"
},
fixable: "whitespace",
messages: eslintFormattingReporter.messages,
schema: [
{
additionalProperties: true,
properties: {
language: {
required: true,
type: "string"
},
languageOptions: {
type: "object"
}
},
type: "object"
}
],
type: "layout"
}
};
const parserPlain = {
meta: {
name: "eslint-parser-plain"
},
..._parserPlain__namespace
};
const index = {
parserPlain,
rules: {
stylua
}
};
module.exports = index;