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
73 lines (69 loc) • 1.57 kB
JavaScript
import * as _parserPlain from 'eslint-parser-plain';
import { Config, Range, formatCode, OutputVerification } from '@isentinel/stylua';
import { reportDifferences, messages } from 'eslint-formatting-reporter';
const stylua = {
create(context) {
const config = Config.new();
const range = Range.from_values();
return {
Program() {
const sourceCode = context.sourceCode.text;
try {
const formatted = formatCode(
sourceCode,
config,
range,
OutputVerification.None
);
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,
schema: [
{
additionalProperties: true,
properties: {
language: {
required: true,
type: "string"
},
languageOptions: {
type: "object"
}
},
type: "object"
}
],
type: "layout"
}
};
const parserPlain = {
meta: {
name: "eslint-parser-plain"
},
..._parserPlain
};
const index = {
parserPlain,
rules: {
stylua
}
};
export { index as default };