Skip to content

Commit

Permalink
chore: add better linting rules (#2107)
Browse files Browse the repository at this point in the history
  • Loading branch information
universalmind303 committed Dec 21, 2021
1 parent 7021980 commit 7a2e0a9
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 148 deletions.
18 changes: 7 additions & 11 deletions nodejs-polars/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,12 @@
"jest"
],
"rules": {
"arrow-spacing": "error",
"eol-last": "error",
"no-inner-declarations": "off",
"func-call-spacing": "off",
"@typescript-eslint/func-call-spacing": [
"error"
],
"no-duplicate-imports": "off",
"@typescript-eslint/no-duplicate-imports": [
"error"
],
"comma-spacing": "off",
"@typescript-eslint/comma-spacing": [
"error"
],
"quotes": [
"error",
"double",
Expand Down Expand Up @@ -64,7 +56,6 @@
"ignoreChainWithDepth": 2
}
],
"@typescript-eslint/member-ordering": "error",
"no-multiple-empty-lines": [
"error",
{
Expand All @@ -79,6 +70,11 @@
"prev": "*",
"next": "return"
}
]
],
"@typescript-eslint/func-call-spacing": "error",
"@typescript-eslint/no-duplicate-imports": "error",
"@typescript-eslint/comma-spacing": "error",
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/type-annotation-spacing": "error"
}
}
44 changes: 22 additions & 22 deletions nodejs-polars/__tests__/dataframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,32 @@ describe("dataframe", () => {
expect(df.toJS()).toEqual(expected);
});
});
test("dtypes", () =>{
test("dtypes", () => {
const expected = ["Float64", "Utf8"];
const actual = pl.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}).dtypes;
expect(actual).toEqual(expected);
});
test("height", () =>{
test("height", () => {
const expected = 3;
const actual = pl.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}).height;
expect(actual).toEqual(expected);
});
test("width", () =>{
test("width", () => {
const expected = 2;
const actual = pl.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}).width;
expect(actual).toEqual(expected);
});
test("shape", () =>{
test("shape", () => {
const expected = {height: 3, width: 2};
const actual = pl.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}).shape;
expect(actual).toEqual(expected);
});
test("columns", () =>{
test("columns", () => {
const expected = ["a", "b"];
const actual = pl.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}).columns;
expect(actual).toEqual(expected);
});
test("clone", () =>{
test("clone", () => {
const expected = pl.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]});
const actual = expected.clone();
expect(actual).toFrameEqual(expected);
Expand All @@ -176,7 +176,7 @@ describe("dataframe", () => {
expect(actual).toFrameEqual(expected);
});
test.todo("downsample");
test("drop", () =>{
test("drop", () => {
const df = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6.0, 7.0, 8.0],
Expand All @@ -191,7 +191,7 @@ describe("dataframe", () => {
const actual = df.drop("apple");
expect(actual).toFrameEqual(expected);
});
test("drop: array", () =>{
test("drop: array", () => {
const df = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6.0, 7.0, 8.0],
Expand All @@ -205,7 +205,7 @@ describe("dataframe", () => {
const actual = df.drop(["apple", "ham"]);
expect(actual).toFrameEqual(expected);
});
test("drop: ...rest", () =>{
test("drop: ...rest", () => {
const df = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6.0, 7.0, 8.0],
Expand All @@ -219,7 +219,7 @@ describe("dataframe", () => {
const actual = df.drop("apple", "ham");
expect(actual).toFrameEqual(expected);
});
test("dropDuplicates", () =>{
test("dropDuplicates", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 2, 3],
"bar": [1, 2, 2, 4],
Expand All @@ -232,7 +232,7 @@ describe("dataframe", () => {
});
expect(actual).toFrameEqual(expected);
});
test("dropDuplicates:subset", () =>{
test("dropDuplicates:subset", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 2, 2],
"bar": [1, 2, 2, 2],
Expand All @@ -245,7 +245,7 @@ describe("dataframe", () => {
});
expect(actual).toFrameEqual(expected);
});
test("dropDuplicates:maintainOrder", () =>{
test("dropDuplicates:maintainOrder", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 2, 2],
"bar": [1, 2, 2, 2],
Expand All @@ -258,7 +258,7 @@ describe("dataframe", () => {
});
expect(actual).toFrameEqual(expected);
});
test("dropNulls", () =>{
test("dropNulls", () => {
const actual = pl.DataFrame({
"foo": [1, null, 2, 3],
"bar": [6.0, .5, 7.0, 8.0],
Expand All @@ -284,7 +284,7 @@ describe("dataframe", () => {

expect(actual).toFrameEqual(expected);
});
test("fillNull:zero", () =>{
test("fillNull:zero", () => {
const actual = pl.DataFrame({
"foo": [1, null, 2, 3],
"bar": [6.0, .5, 7.0, 8.0],
Expand All @@ -297,7 +297,7 @@ describe("dataframe", () => {
});
expect(actual).toFrameEqual(expected);
});
test("fillNull:one", () =>{
test("fillNull:one", () => {
const actual = pl.DataFrame({
"foo": [1, null, 2, 3],
"bar": [6.0, .5, 7.0, 8.0],
Expand Down Expand Up @@ -841,15 +841,15 @@ describe("dataframe", () => {
expect(actual.row(0)).toEqual([1, 0, 0, 2]);
});
test.todo("pipe");
test("quantile", ()=>{
test("quantile", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
"ham": ["a", "b", "c"]
}).quantile(0.5);
expect(actual.row(0)).toEqual([2, 7, null]);
});
test("rename", ()=>{
test("rename", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
Expand All @@ -861,7 +861,7 @@ describe("dataframe", () => {
});
expect(actual.columns).toEqual(["foo_new", "bar_new", "ham_new"]);
});
test("replaceAtIdx", ()=>{
test("replaceAtIdx", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
Expand All @@ -872,15 +872,15 @@ describe("dataframe", () => {
expect(actual.getColumn("new_foo")).toSeriesEqual(s);
expect(actual.findIdxByName("new_foo")).toEqual(0);
});
test("row", ()=>{
test("row", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
"ham": ["a", "b", "c"]
}).row(1);
expect(actual).toEqual([2, 7, "b"]);
});
test("rows", ()=>{
test("rows", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
Expand Down Expand Up @@ -1166,7 +1166,7 @@ describe("dataframe", () => {
const readStream = new Stream.Readable();
expect(() => df.toCSV(readStream)).toThrow();
});
test("toJSON:string", () =>{
test("toJSON:string", () => {
const rows = [
{foo: 1.1, bar: 6.2, ham: "a"},
{foo: 3.1, bar: 9.2, ham: "b"},
Expand Down Expand Up @@ -1214,7 +1214,7 @@ describe("dataframe", () => {
const readStream = new Stream.Readable();
expect(() => df.toJSON(readStream)).toThrow();
});
test("toSeries", () =>{
test("toSeries", () => {
const s = pl.Series([1, 2, 3]);
const actual = s.clone().toFrame().toSeries(0);
expect(actual).toSeriesEqual(s);
Expand Down
4 changes: 2 additions & 2 deletions nodejs-polars/__tests__/expr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ describe("expr.str", () => {

});
describe("expr.lst", () => {
test("get", () =>{
test("get", () => {
const df = pl.DataFrame({"a": [[1, 10, 11], [2, 10, 12], [1]]});
const expected = pl.DataFrame({"get": [11, 12, null]});
const actual = df.select(
Expand All @@ -1384,7 +1384,7 @@ describe("expr.lst", () => {
expect(actual).toFrameEqual(expected);
expect(actualFromSeries).toFrameEqual(expected);
});
test("first", () =>{
test("first", () => {
const df = pl.DataFrame({"a": [[1, 10], [2, 10]]});
const expected = pl.DataFrame({"first": [1, 2]});
const actual = df.select(
Expand Down
2 changes: 1 addition & 1 deletion nodejs-polars/__tests__/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ describe("repeat", () => {

expect(actual).toSeriesEqual(expected);
});
});
});
2 changes: 1 addition & 1 deletion nodejs-polars/__tests__/groupby.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ describe("groupby", () => {
});
test.todo("groups");

});
});
2 changes: 1 addition & 1 deletion nodejs-polars/__tests__/io.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ describe("io", () => {
it.todo("can read from a stream");
});
});
});
});
2 changes: 1 addition & 1 deletion nodejs-polars/__tests__/lazy_functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,4 @@ describe("lazy functions", () => {
const actual = df.select(pl.tail(col("a"), 2)).getColumn("a");
expect(actual).toSeriesEqual(expected);
});
});
});
26 changes: 13 additions & 13 deletions nodejs-polars/__tests__/lazyframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("lazyframe", () => {
`TABLE: ["foo", "bar"]; PROJECT */2 COLUMNS; SELECTION: None\\n
PROJECTION: None`);
});
test("drop", () =>{
test("drop", () => {
const df = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6.0, 7.0, 8.0],
Expand All @@ -62,7 +62,7 @@ describe("lazyframe", () => {
.collectSync();
expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("drop:array", () =>{
test("drop:array", () => {
const df = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6.0, 7.0, 8.0],
Expand All @@ -78,7 +78,7 @@ describe("lazyframe", () => {
.collectSync();
expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("drop:rest", () =>{
test("drop:rest", () => {
const df = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6.0, 7.0, 8.0],
Expand Down Expand Up @@ -109,7 +109,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("dropDuplicates:subset", () =>{
test("dropDuplicates:subset", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 2, 2],
"bar": [1, 2, 2, 2],
Expand All @@ -124,7 +124,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("dropDuplicates:maintainOrder", () =>{
test("dropDuplicates:maintainOrder", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 2, 2],
"bar": [1, 2, 2, 2],
Expand Down Expand Up @@ -169,7 +169,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("dropNulls:rest", () =>{
test("dropNulls:rest", () => {
const actual = pl.DataFrame({
"foo": [1, null, 2, 3],
"bar": [6.0, .5, null, 8.0],
Expand Down Expand Up @@ -199,7 +199,7 @@ describe("lazyframe", () => {

expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("fetch", () =>{
test("fetch", () => {
const df = pl.DataFrame({
"foo": [1, 2],
"bar": ["a", "b"]
Expand All @@ -214,7 +214,7 @@ describe("lazyframe", () => {
.fetch(1);
expect(actual).toFrameEqual(expected);
});
test("fillNull:zero", () =>{
test("fillNull:zero", () => {
const actual = pl.DataFrame({
"foo": [1, null, 2, 3],
"bar": [6.0, .5, 7.0, 8.0],
Expand All @@ -229,7 +229,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("fillNull:expr", () =>{
test("fillNull:expr", () => {
const actual = pl.DataFrame({
"foo": [1, null, 2, 3],
"bar": [6.0, .5, 7.0, 8.0],
Expand Down Expand Up @@ -270,7 +270,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqual(expected);
});
describe("groupby", () =>{});
describe("groupby", () => {});
test("head", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
Expand Down Expand Up @@ -605,7 +605,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqual(expected);
});
test("quantile", ()=>{
test("quantile", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
Expand All @@ -615,7 +615,7 @@ describe("lazyframe", () => {
.collectSync();
expect(actual.row(0)).toEqual([2, 7, null]);
});
test("rename", ()=>{
test("rename", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 3],
"bar": [6, 7, 8],
Expand Down Expand Up @@ -998,4 +998,4 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqual(expected);
});
});
});

0 comments on commit 7a2e0a9

Please sign in to comment.